[SATLUG] small script, baffled problem.
dkowis at shlrm.org
Wed Aug 11 17:59:04 CDT 2010
-----BEGIN PGP SIGNED MESSAGE-----
On 08/11/2010 04:26 PM, Richard Suberg wrote:
> I can't find anything anywhere that helps me out with this one. I have a
> simple script that mounts by ftp and then copies data from that server to
> mine. Problem is if the mount fails (other server changes password or just
> connect fails) it wipes out the destination and doesn't tell me anything. I
> decided to add an if clause after the mount, and after that on failures I
> get either syntax error near unexpected token '}' or near unexpected token
> 'fi' or near unexpected token 'else'. I even run into unexpected end of
> file, just depends on what is at the end of the file. I would like to have
> an error-processing routine that would let me know somehow that it failed,
> but if it just skips the copy on mount failed that would be better than
> I'm totally baffled, and just see how many hits you get trying to search for
> if then else ubuntu.even tried what I found there, (using brackets, fi, .)
> and no help. Hopefully someone can see the problem easily.
Simple fix: you forgot a semicolon
if $?=0 ; then
if and then are separate statements, so they have to have a semicolon or
be on different lines.
Also, when you test your exit=? that changes the exit code, better would
be to store your exit code immediately
echo "exit = $EXIT_CODE"
Also I wouldn't put the exit 0 in there, I'd let it fall out normally :)
> - - - - -
> curlftpfs 188.8.131.52 /remote -o allow_other,user=user:pass -v
> echo exit=$?
> if $?=0 then
> echo Processing...
> cp -uRv /remote/* /share/DSD/
> chmod -R 777 /share
> umount /remote
> echo done
> exit 0
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
-----END PGP SIGNATURE-----
More information about the SATLUG