/ Sign-up
Your question

Shell Script help

  • Shell Script
  • Programming
  • Command Prompt
Last response: in Open Source Software
August 30, 2010 5:50:37 PM

I'm creating some disc images using cdrdao and I want to put it into a shell script so that it'll ask me for the output path/file, this way I can just run the program do a little input and let it do its thing. I would assume I would use the read command, but I'm horrible at anything even remotely close to programming.

More about : shell script

Best solution

a b L Programming
August 31, 2010 8:27:22 PM

Are you wanting to input just one file name or many? If just one the easiest approach would be to give it as a parameter to the script file and access it via the variable $1. So your comand line would be something like:

process outputfilename

and then inside the script $1 will have the value of outputfilename.

If you need to enter a number of filenames one after the other, then the read function would be a better option. Again, fairly straightforward; in the script a line like:

read filename

would put the filename entered into the variable $filename. Have a look at this link for more details, and for information about shell programming in general.
September 10, 2010 5:21:42 AM

Best answer selected by horrormaster.