Results 1 to 3 of 3
i'm trying to check if both files exist and if they do i will run a code block to be developed later; otherwise skip. The files im checking need a ...
- 09-26-2011 #1Just Joined!
- Join Date
- Oct 2010
- Posts
- 14
errors when trying to run file checks (bash)
i'm trying to check if both files exist and if they do i will run a code block to be developed later; otherwise skip. The files im checking need a date variable and a wildcard. i peiced together some code from forums but recieved many erros shown below
Code:backup:/home/myuser . /dir1/dir2/myuser_test.sh ' is not a typo you can run the following command to lookup the package that contains the binary: command-not-found : command not found ' is not a typo you can run the following command to lookup the package that contains the binary: command-not-found : command not found ' is not a typo you can run the following command to lookup the package that contains the binary: command-not-found : command not found ' is not a typo you can run the following command to lookup the package that contains the binary: command-not-found : command not found ' is not a typo you can run the following command to lookup the package that contains the binary: command-not-found : command not found will execute ' is not a typo you can run the following command to lookup the package that contains the binary: command-not-found : command not found backup:/home/myuser # cat /dir1/dir2/myuser_test.sh #!/bin/bash DATE=`date +%Y%m%d` #DATE=`date --date="yesterday" +%Y%m%d` #echo $DATE if [ ! -f /backup/$DATE*file.zip -o ! -f /backup/$DATE*dirs.zip ]; then echo "will execute" else echo "Did not find /backup/$DATE*file.zip /backup/$DATE*dirs.zip. Skipping." fi
- 09-27-2011 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
I'm not sure where that error message is coming from, but it looks like you are sourcing the script, versus running it. Does running it cause the same error? e.g.:
Maybe your wildcards are doing something unexpected when you are sourcing it...Code:chmod +x /dir1/dir2/myuser_test.sh cd /dir1/dir2 ./myuser_test.sh
- 09-28-2011 #3Just Joined!
- Join Date
- Dec 2006
- Posts
- 3
Hi
I faced many times quite similar problem of gettings errors quite different.
I am not sure if you have the same issue but worth giving it a try if not already done.
Since you say that you have took some code from forum, i suspect that there could be some invisible special char in the script.
try giving a dummy echo "check" after #!/bin/bash and run the script to see if you could see the echoed stgring. If not, then try running dos2unix on the script and execute it again.
Hope it helps. Good luck
Collins


Reply With Quote