You are not logged in.
Pages: 1
can i make a bash script to do something like this? i also know a little bit of C, but it seems like bash script might make more sense for the job.
i'm trying to make a script that would allow the user to enter a variable, and then use that variable to execute dd. so for instance, i want to make and ISO file named 'whatever.iso", so i could have the user type in "whatever", and it would execute "dd if=/dev/sr0 of=whatever.iso blah blah lots of options". what would be the best way to do something like this?
Offline
Your arguments start counting at 1 (the command itself being $0). So you could do
#!/bin/bash
dd if="$1" of="$2"
That's the basic version. You could also provide a help function that not only displays if --help is called e.g. but also if not enough parameters are given.
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
B has given you a good start... Read up on bash 'if' statements and make sure you put some tests in there to make sure the user hasn't entered "/dev/sda" as argument #2, or you'll be in trouble(!)
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
And be extra careful with those scripts!
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...
Offline
Pages: 1