LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-09-2008, 04:27 AM   #1
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 598

Rep: Reputation: 30
Scripting help needed.


Hi All,


Once again I need all your help to get things. I am using the following script to login to ftp and pull a particular file.

Code:
#!/bin/bash
ip=192.168.1.10
user=zamo
pwd=zamo1

cd /tmp
ftp -n $ip << inp
quote user $user
quote pass $pwd
put sample1.txt
exit
inp

Now, as am moving forward, I have to make some changes here.
Code:
#!/bin/bash
ip=192.168.1.10
user=zamo
pwd=zamo1
dir_path=/dir1/dir2/dir3
dest_file=myfile

cd /tmp
ftp -n $ip << inp
quote user $user
quote pass $pwd
put $dir_path/($dest_file)_$(date +\%F)
exit
inp

I need to "put" (download) a variable file from the FTP server. As the variables assigned in this script are not working , as it logged inside the FTP. Is there anyway to do this.
 
Old 09-09-2008, 04:52 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
I think you have to split the put statement in two parts:
Code:
lcd $dir_path
put ${dest_file}_$(date +%F)
otherwise the local path is not interpreted correctly. Moreover, I slightly modified the put statement since I don't see the need to open a subshell to expand the file name and the reason for escaping the % sign. Cheers!
 
Old 09-09-2008, 06:11 AM   #3
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 598

Original Poster
Rep: Reputation: 30
Thanks A Lot Colucix. Its Working
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
a little scripting help needed!! vatsan1 Linux - General 6 09-02-2007 08:50 AM
Bash scripting help needed Zylar Linux - Newbie 8 05-03-2007 08:32 AM
shell scripting - help needed jonhewer Linux - Newbie 54 09-09-2005 02:58 PM
bash scripting --- some help needed rajsharma Linux - Software 1 09-09-2005 02:49 AM
Scripting help needed. stonelee Linux - Software 2 09-29-2003 09:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:29 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