Read and execute set of linux commands from file
Following is the set of commands to execute one by one
commands.txt Code:
/bin/date check.sh Code:
#!/bin/bash 1. top: unknown argument ' 2. /bin/df: invalid option 3. tail: invalid option -- 1 4. sh: line 14: /usr/local/bin/iostat: No such file or directory 5. /bin/netstat: invalid option -- I made this script as this also Code:
run () { |
I think you are being bitten by white space/new line problems. What happens if you try the following?
Code:
while read line ; do Evo2. |
Thanks Evo...
Umm.. the syntax is similar and no success still same error return |
Adding carriage return characters to some of your commands gives error messages similar to yours.
Does the command file have Windows line endings '\r\n' instead of Linux '\n'? Code:
# $'\r' creates a carriage return character in bash |
when i run all these commands one by one from a text file, its skip the arguments
Ex:- /bin/grep -i error /var/log/messages --> its just only execute the "grep" command and return error no argument passed to this grep Code:
Usage: grep [OPTION]... PATTERN [FILE]... |
Thanks Kenhelm... Yup It caused because of windows file. now converted it as linux file (with dos2unix help)
|
All times are GMT -5. The time now is 02:06 AM. |