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.

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 02-24-2009
Sagarddd Sagarddd is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 12
Need a FTP help

Hi,

After connecting to the remote server by using FTP i need to know the file name residing on the remote path....So that that file name i can pass as a parameter to the main program...FTP program will get called from the main program....

Please let me know the solution.
  #2 (permalink)  
Old 02-24-2009
anchal_khare anchal_khare is offline
Registered User
  
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 325
sorry .. i am not able to undrstand ur requirement.
You should know the filename you want to FTP !!!
there can be lots of files in any specific remote path....

You can get them listed by "ls".

Last edited by anchal_khare; 02-24-2009 at 10:30 AM..
  #3 (permalink)  
Old 02-24-2009
Sagarddd Sagarddd is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 12
Question

i will be having just one file at a time in remote path.....by using ls i will list it....but how will i pass that file name as parameter to main program....?
  #4 (permalink)  
Old 02-24-2009
anchal_khare anchal_khare is offline
Registered User
  
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 325
This is one approach...



Getval=`ftp -n -i $RemoteHost <<EOF 2>&1
user $user $Passwd
cd $RemotePath
ls
bye
EOF`

RemoteFile=`echo $Getval | grep $user | awk '{ print $NF }'`
echo $RemoteFile


you can change the grep parameter as per ur pattern ( date or something else) to filter the "ls" string.
  #5 (permalink)  
Old 02-24-2009
anchal_khare anchal_khare is offline
Registered User
  
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 325
Quote:
RemoteFile=`echo $Getval | awk '{ print $NF }'`

You can remove grep ...
this should work...

Last edited by anchal_khare; 02-24-2009 at 10:30 AM..
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 10:50 PM.


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