The UNIX and Linux Forums  
Hello and Welcome from to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Call a perl script inside a shell script chriss_58 Shell Programming and Scripting 3 12-01-2008 04:28 AM
invoking a shell script inside cgi shell script smriti_shridhar Shell Programming and Scripting 2 07-09-2008 02:50 AM
How to run an SQL script inside a shell stevefox Shell Programming and Scripting 1 06-15-2006 11:11 PM
How to run unix commands in a new shell inside a shell script? hkapil Shell Programming and Scripting 2 01-04-2006 06:56 AM
Using tar inside a shell script kas7225 Shell Programming and Scripting 2 05-20-2005 12:06 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-03-2009
Dendany83 Dendany83 is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 4
Question How to use ftp commands inside shell script? Help please

Dears,

I'm new in shell scripting and i need your help, i would like to know how can i create a script to ftp to a certain unix/linux machine/server IP address and get a file for example without user intervention? How can i force the script to use a certain username and password to access this machine then execute the "change directory" to go to a certain path and get the requested file?

I appreaciate your help

Many thanks in advance
  #2 (permalink)  
Old 04-03-2009
siquadri siquadri is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 44
quote=Dendany83;302303901]Dears,

I'm new in shell scripting and i need your help, i would like to know how can i create a script to ftp to a certain unix/linux machine/server IP address and get a file for example without user intervention? How can i force the script to use a certain username and password to access this machine then execute the "change directory" to go to a certain path and get the requested file?

I appreaciate your help

Many thanks in advance[/quote]

Your can shell as follows
shellname ftpservername userid password localdir remotedir filename

Code:
#!/bin/ksh
LANHOST=$1
USER=$2
PASSWD=$3
SRCDIR=$4
DATAIN=$5
FILENAME=$6
ftp -nv ${LANHOST} <<END
user ${USER} ${PASSWD}
cd  ${SRCDIR}
lcd ${DATAIN}
get ${FILENAME} 
bye
END
  #3 (permalink)  
Old 04-03-2009
Dendany83 Dendany83 is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 4
Thanks Siquadri for your propmt reply, i will try it
  #4 (permalink)  
Old 04-04-2009
amitranjansahu's Avatar
amitranjansahu amitranjansahu is offline
Registered User
  
 

Join Date: Jan 2009
Location: Gurgaon,INDIA
Posts: 239
ftp -v -n "172.21.142.108" << cmd
user "amit" "12345678"
cd /export/home/amit
lcd /export/home/voipa9/
bin
hash
get $1
quit
cmd
  #5 (permalink)  
Old 04-06-2009
TonyLawrence TonyLawrence is offline
Registered User
  
 

Join Date: Sep 2007
Location: SE Mass
Posts: 145
Yes, you CAN do the scripting as suggested above. However, if anything goes wrong, those simplistic scripts will fail unpleasantly.

Nowadays I really recommend using simple Perl scripts for this kind of task. It's not at all hard - see Perl Net::FTP for an introduction.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:41 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0