Creating a script to run two commands
Hi all,
I would like to create a script that runs two commands. One of the command has lot of aruguments along with the command. Any help is appreciated. Thanks in advance. |
You haven't indicated what you are trying to accomplish, or even what type of script you are writing, bash, perl, python?
|
script.sh
Code:
/path/to/command a really long set of options that go on for ever can be placed like this there is really nothing else to it |
Sorry....in bash
=========== #!/bin/bash command 1 command 2 ============ above doesn't work |
create a file called something like script.sh
edit the file to contain the following Code:
#!/bin/bash To run the script try Code:
$ ./script.sh |
those lots of arguments are running in over 3 lines...how will it differentiate between end of command 1 and start of command 2 ? Plus command one gives error on the second line..it thinks its a new command.
|
The backslash '\'
Code:
#!/bin/bash |
David Ross,
We must have posted nearly simultaneously. Good Suggestion!!! |
woo hoo .. its working ... u guys are the best :)
Thanks vey much!!! |
[QUOTE]those lots of arguments are running in over 3 lines...[quote]3 lines is not that much. To have bash confused over large command lines, - if ever - you probably need thousands (millions?) of lines!
Quote:
However, if it bothers you (or your editor) to have such long lines in the script, then spread the command over several lines and finish all but the last line with a backslash ( \ ). Nothing (not even spaces or tabs) should go after the backslash. Like this: Code:
commandONE \ |
Sorry I was a litte curt on my answer. The second sentence didn't sink in.
|
take care and don't put a space or any other character after the \
|
All times are GMT -5. The time now is 07:42 PM. |