LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Silly mistake in lftp bash script probably quotes (http://www.linuxquestions.org/questions/linux-software-2/silly-mistake-in-lftp-bash-script-probably-quotes-4175449000/)

emmalg 02-07-2013 06:09 AM

Silly mistake in lftp bash script probably quotes
 
Hi,

I have made a but of a simple error somewhere in a script I am writing. I blame it on lack of practice as it's the first script I've done since being on maternity leave for a year... I could not get my head around the quotes at all!

And yeah I know about the password in plain text just live with it for now.

Here goes:

Code:

#!/bin/bash

R_FTP='someip'
USR='user'
PSWD='password'
L_DIR='/local/dir/'
R_DIR='/remote/dir/'

TO='set net:timeout 30'

/usr/bin/lftp -e \'"$TO; mirror -R $L_DIR $R_DIR"\' -u $USR,$PSWD $R_FTP

If I pop echo in front of the /usr/bin/lftp the output is as I expect and that works fine if copied onto the command line.

If I try to run the script however it seems to ignore the lftp and I get:
Unknown command `set net:timeout 30; mirror -R /local/dir/ /remote/dir/'.

I'd be grateful for a bit of assistance, I need to get the data uploaded quickly!

Cheers
Emma

foodown 02-07-2013 02:44 PM

Try ...

Code:

/usr/bin/lftp -e "${TO}; mirror -R ${L_DIR} ${R_DIR}" -u ${USR},${PSWD} ${R_FTP}

chrism01 02-07-2013 07:18 PM

Also, you can see what the parser really does by adding
Code:

#!/bin/bash
set -xv


emmalg 02-08-2013 05:12 AM

Thanks guys! Both super helpful (I am kicking myself at the moment).


All times are GMT -5. The time now is 08:14 PM.