Hi there,

I'm currently trying to write a simple bash shell script that
recursively loops through a directory and for each directory entry
will mirror the contents to a remote backup server.  In principal
everything works fine when i step through the commands step by step.

One big issue I am having however is integrating the commands into a
shell script.

One of the limits of shell scripting, is that by placing single quotes
( ' ) within a shell script, variable expansion doesn't occur between
the single quotes ..

#!/bin/sh
backupDirectory="/tmp/somedir/for/backups"
for backupDir in `ls -1 ${backupDirectory}/`;
    msg="attempting backup on ${backupDir}: -- [ "
    cmdString="mirror -R ${backupDirectory}/${backupDir} backups/${backupDir}"
    # no keyword expansion
    ${ftpProgram} -c 'open -e \"${cmdString}\" ${siteUrl}'

    # no errors , return code of 0 but doesn't transfer files remotely
    # ${ftpProgram} -c \'open -e \"${cmdString}\" ${siteUrl}\'

    cmdStatus=${?}
     if [ ${cmdStatus} -gt 0 ]; then
            msg="${msg} failed ] --"
     else
             msg="${msg} success ] --"
     fi
done

The above is what I have.  The variables aren't expanded.  When I
escape the single quotes with a backslash ( \ ) the command is shown
properly and returns a return code of 0 -- ( $? == 0 ) . . however,
nothing is actually done.  I can confirm this when I run it command
line with the single quotes escaped.

Now, I realize that my problems are more limitations with the shell
scripting environment I'm using rather then lftp, however, I'm
emailing in  hope that someone on this list knows of another way I can
work around this?

All the best

--
Sasha Dolgy
http://sasha.dolgy.com/
[EMAIL PROTECTED]

Reply via email to