[SATLUG] small script, baffled problem.

Richard Suberg rsuberg at satx.rr.com
Thu Aug 12 21:14:33 CDT 2010

Thanks, what I did was put the ; in there, then was able to take out the
exit and put in an else clause...now to have the thing let me know when it
fails (would be in the else clause) but how to do it? telnet to the mail
server? This box just sits there serving documents, has apache loaded, but
no external mail setups.  I knew it was going to be something simple...


-----Original Message-----
From: satlug-bounces at satlug.org [mailto:satlug-bounces at satlug.org] On Behalf
Of David Kowis
Sent: Wednesday, August 11, 2010 5:59 PM
To: The San Antonio Linux User's Group Mailing List
Subject: Re: [SATLUG] small script, baffled problem.

Hash: SHA1

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 nothing.
> 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

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 EXIT_CODE=$?

echo "exit = $EXIT_CODE"

Also I wouldn't put the exit 0 in there, I'd let it fall out normally :)

> - - - - -
> curlftpfs /remote -o allow_other,user=user:pass  -v
> echo exit=$?
> if  $?=0   then 
>  echo Processing...
>  date
>  cp -uRv /remote/* /share/DSD/
>  chmod -R 777 /share
>  umount /remote
>  echo done
>  exit 0
> fi

Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

SATLUG mailing list
SATLUG at satlug.org
http://alamo.satlug.org/mailman/listinfo/satlug to manage/unsubscribe
Powered by Rackspace (www.rackspace.com)

More information about the SATLUG mailing list