LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-29-2006, 08:38 AM   #1
A.S.Q.
LQ Newbie
 
Registered: Sep 2006
Posts: 3

Rep: Reputation: 0
Variable expansion inside of a bash script!


I am having problems trying to get the following command working inside of a bash script:

Code:
lftp -c 'open -e "put file-name-$DATE.tar" 10.0.0.1/dir/here -u uname,password'
When this command runs from inside of the script it gives the following error:

Code:
put: file-name-$DATE.tar: No such file or directory
This is obviously because the variable $DATE (which is defined previously in the script) isn't being expanded due to the single quotes (and possibly the combo of double quotes inside). When I escape various combinations of them, however, the command still doesn't work. In true "lftp" manner it doesn't error out, it just simply doesn't do anything.

Any ideas?
 
Old 09-29-2006, 08:46 AM   #2
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,245
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
perhaps this will work...

# eval "lftp -c 'open -e \"put file-name-$DATE.tar\" 10.0.0.1/dir/here -u uname,password'"

OR

# lftp -c 'open -e "put file-name-'$DATE'.tar" 10.0.0.1/dir/here -u uname,password'

Last edited by konsolebox; 09-29-2006 at 08:54 AM.
 
Old 09-29-2006, 09:04 AM   #3
olaola
Member
 
Registered: Aug 2006
Location: Italy
Distribution: Fedora
Posts: 41

Rep: Reputation: 15
I think you shuold use

Code:
lftp -c \'open -e "put file-name-$DATE.tar" 10.0.0.1/dir/here -u uname,password\'
 
Old 09-29-2006, 09:09 AM   #4
A.S.Q.
LQ Newbie
 
Registered: Sep 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by olaola
I think you shuold use

Code:
lftp -c \'open -e "put file-name-$DATE.tar" 10.0.0.1/dir/here -u uname,password\'
This doesn't work.
 
Old 09-29-2006, 09:09 AM   #5
A.S.Q.
LQ Newbie
 
Registered: Sep 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by konsolebox
perhaps this will work...
# lftp -c 'open -e "put file-name-'$DATE'.tar" 10.0.0.1/dir/here -u uname,password'
This does! Thanks for the assistance.
 
  


Reply


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
[SOLVED] issue with variable in bash script angel115 Programming 4 08-21-2006 01:42 PM
Bash Script Expansion Problem meadensi Linux - Newbie 1 03-04-2005 05:17 PM
how do i kill a process from inside a bash script? mikaelo Programming 4 05-28-2004 08:51 AM
Pipe inside variable isn't working in bash Reginald0 Linux - General 5 01-30-2004 09:43 AM
bash script $n variable expansion cortez Programming 6 12-08-2003 04:03 PM


All times are GMT -5. The time now is 04:38 AM.

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