LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
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



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
Pipe inside variable isn't working in bash Reginald0 Linux - General 6 12-09-2015 09:56 AM
[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
bash script $n variable expansion cortez Programming 6 12-08-2003 04:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:45 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration