The UNIX and Linux Forums  

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
shell program nivas Shell Programming and Scripting 8 02-21-2008 05:23 AM
help with shell program adgarg Shell Programming and Scripting 3 10-31-2007 06:54 AM
shell program rameshparsa Shell Programming and Scripting 1 11-17-2005 01:18 PM
Shell Program TexasGuy High Level Programming 3 03-12-2005 02:11 AM
Help me with this Shell Program TRUEST Shell Programming and Scripting 1 04-08-2002 12:58 PM

Reply
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 07-10-2009
raghav1982 raghav1982 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 101
Shell Program , need help!!

Hi all,

I am trying to get a file from an ftp server and i have the list of files which needs to be get from the ftp server.

grep unix_prg*.* log.txt > log1.txt

log1.txt (which has the list of files)

06-29-09 00:00AM 3550258 unix_prg090629
06-28-09 07:00PM 115733 unix_prg090628
06-27-09 07:02AM 1025004 unix_prg090627
06-26-09 07:12PM 5399554 unix_prg090626
06-25-09 07:09PM 4111899 unix_prg090625
06-24-09 07:05PM 2012520 unix_prg090624
06-23-09 07:07PM 2950387 unix_prg090623
06-22-09 07:09PM 4080367 unix_prg090622
06-21-09 07:01PM 322285 unix_prg090621


if i am using the command head -1 log1.txt > log2.txt

log2.txt (output file)

06-29-09 00:00AM 3550258 unix_prg090629

i got the exact file which i need to take it from ftp server.


How can i invoke the same , i need a way to get the file from that server ??

Just need to login to the ftp server and get the file which is printed in log2.txt


Thanks!!
  #2 (permalink)  
Old 07-10-2009
rakeshawasthi rakeshawasthi is offline
Registered User
  
 

Join Date: Aug 2004
Location: India
Posts: 379
You may like to try FTP yourself first...
Read here first.
Automate FTP / Scripting FTP Transfers
  #3 (permalink)  
Old 07-10-2009
raghav1982 raghav1982 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 101
Quote:
Originally Posted by rakeshawasthi View Post
You may like to try FTP yourself first...
Read here first.
Automate FTP / Scripting FTP Transfers
Thankyou!! i have tried couple of times, not able to get the condition which i need,

Can anyone help me on this ??

Thanks!
  #4 (permalink)  
Old 07-10-2009
lathavim lathavim is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 73
Hi, Can u show the script u r using to ftp the file? What issue u r facing exactly?
  #5 (permalink)  
Old 07-10-2009
raghav1982 raghav1982 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 101
Code:
ftp -nv $HOST > log.txt << END_SCRIPT
   quote USER $USER_show
   quote PASS $PASSWD_show1
cd unix1
   ls -ltr
quit
exit 0
grep unix_prg*.* log.txt > log1.txt 
head -1 log1.txt > log2.txt
log1.txt (which has the list of files)

Code:
06-29-09  00:00AM              3550258 unix_prg090629
06-28-09  07:00PM               115733 unix_prg090628
06-27-09  07:02AM              1025004 unix_prg090627
06-26-09  07:12PM              5399554 unix_prg090626
06-25-09  07:09PM              4111899 unix_prg090625
06-24-09  07:05PM              2012520 unix_prg090624
06-23-09  07:07PM              2950387 unix_prg090623
06-22-09  07:09PM              4080367 unix_prg090622
06-21-09  07:01PM               322285 unix_prg090621

log2.txt (output file)

Code:
06-29-09  00:00AM              3550258 unix_prg090629
i got the exact file which i need to take it from ftp server.



from here i am not sure how to get the file which is in log2.txt ??

thanks

Last edited by vgersh99; 07-10-2009 at 09:26 AM.. Reason: code tags, PLEASE!
Bits Awarded / Charged to raghav1982 for this Post
Date User Comment Amount
07-10-2009 vgersh99 added code tags - charged 5K bits -5,000
  #6 (permalink)  
Old 07-10-2009
lathavim lathavim is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 73
This is the sample script to ftp a file.


Code:
 
HOST='host'
USER='yourid'
PASSWD='yourpw'
LOCAL_PATH='path'
REMOTE_PATH='remote_path'
FILE='filename'
ftp -n <<EOF
open $HOST
user $USER $PASSWD
cd $REMOTE_PATH
get $FILE $LOCAL_PATH
quit
EOF
exit 0
  #7 (permalink)  
Old 07-10-2009
lathavim lathavim is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 73
Subsitute filename as below.


Code:
 
FILE=`awk -F " " '{print $4}' log2.txt`
Reply

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 11:16 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