LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 02-07-2013, 07:09 AM   #1
emmalg
Member
 
Registered: Jun 2009
Location: Spain
Distribution: Various, Ubuntu, Fedora, Open Solaris, Solaris, RHEL, CentOS
Posts: 64

Rep: Reputation: 16
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
 
Old 02-07-2013, 03:44 PM   #2
foodown
Member
 
Registered: Jun 2009
Location: Texas
Distribution: Slackware
Posts: 609

Rep: Reputation: 218Reputation: 218Reputation: 218
Try ...

Code:
/usr/bin/lftp -e "${TO}; mirror -R ${L_DIR} ${R_DIR}" -u ${USR},${PSWD} ${R_FTP}
 
1 members found this post helpful.
Old 02-07-2013, 08:18 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,311

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Also, you can see what the parser really does by adding
Code:
#!/bin/bash
set -xv
 
1 members found this post helpful.
Old 02-08-2013, 06:12 AM   #4
emmalg
Member
 
Registered: Jun 2009
Location: Spain
Distribution: Various, Ubuntu, Fedora, Open Solaris, Solaris, RHEL, CentOS
Posts: 64

Original Poster
Rep: Reputation: 16
Thanks guys! Both super helpful (I am kicking myself at the moment).
 
  


Reply

Tags
lftp, script, variables


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script to lftp mirror and log zimbot Linux - General 6 09-23-2013 08:55 AM
calling lftp from a bash script; howto pass variables into the command syntax stvy Programming 2 01-09-2013 02:43 PM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 12:10 PM
Silly bash script programming.... ArthurHuang Programming 12 02-14-2008 08:56 AM
same find command not working in bash script, quotes? QuakerOatz Linux - Software 1 07-14-2003 01:04 PM


All times are GMT -5. The time now is 06:40 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration