Command line automization question
Hello
I m a complete newbie on linux (know a little r). I am using imagemagick and need to excecute a simple command in different directories. Because the command takes some time I would have to enter it... then wait then , once its done (beacuse parallel would crash the system), change the folder , enter commandline again, etc you get the picture. I m looking for a way that I could do that automatically. so the process is cd a montage something make asomething cd .. cd b montage something make bsomething etc How could i enter that(commandline folderchange; command line folder change) in the terminal so i could get it to just run all night? Thank you very much. very much philip |
You can write a bash script.
For example, add this to a file and save #!/bin/bash cd a montage something make asomething cd .. cd b montage something make bsomething etc Then $ chmod +x myfilename <- Makes the file executable $ ./myfilename <-runs the scripts |
yes i figured this much.
But how would i do that? Cant i just type the commands: so path/ commandline next path commandline next path commandline ? how would such a script have to look? |
A bash script is just a regular terminal. The commands would be the same as you would type in the terminal
just add #!/bin/bash to the top of your script and type exactly what you would type if you were entering the commands in yourself If you were doing it manually with the commands: cd a montage something make asomething cd .. cd b montage something make bsomething etc put that right in the bash script. You can cd in a bash script, you can do anything you could normally do at a terminal. There is no extra syntax. Is this what you're asking? Or am I understanding wrong? |
You can also just put it all in one line on the command line:
Code:
cd a && montage something && make asomething && cd .. && cd b && montage something && make bsomething |
thanks
it seems to be runnign like a charme. i wonder though because the script hasnt gotten there. is it with or without spacing the entire thing? Well I ll see tomorrow morning. But this helps me trmendously!!!! Thank you p |
A script of what I typed would look like the following, just one command on each line.
Code:
#!/bin/sh |
If you create a list of directories with files to be processed, then you could loop thru that list.
Code:
((dirlist is a file containing all the directory name)) |
Member Response
Hi,
Welcome to LQ! Quote:
Just a few links to aid you to gaining some understanding. 1 Linux Documentation Project 2 Rute Tutorial & Exposition 3 Linux Command Guide 4 Bash Beginners Guide 5 Bash Reference Manual 6 Advanced Bash-Scripting Guide 7 Linux Newbie Admin Guide 8 LinuxSelfHelp 9 Utimate Linux Newbie Guide The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links! FYI: I suggest that you look at 'How to Ask Questions the Smart Way' so in the future your queries provide information that will aid us in diagnosis of the problem or query. |
All times are GMT -5. The time now is 12:41 PM. |