The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
comands inside the script mercuryshipzz Security 4 02-13-2008 12:25 PM
while loops nymus7 Shell Programming and Scripting 4 03-31-2006 09:59 AM
how to identify the type of shell using comands.. swamymns Shell Programming and Scripting 2 01-17-2006 09:17 PM
External comands in C? merlin High Level Programming 2 01-07-2003 09:15 PM
loops? jonas27 UNIX for Dummies Questions & Answers 1 11-05-2001 11:28 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-01-2004
Registered User
 

Join Date: Jul 2004
Posts: 6
Question For Loops Within Ftp Comands

I am having trouble getting files to ftp over when I run the file names through a loop. If I just do one file it works, but inside of a for loop it does not.

Help!

################section 2

cd /home/salazar/chk_data
chmod 777 *
ftp -n 161.241.--.-- <<!
user anonymous \n
ascii

for job2 in 3t 11 12 13 14 18 19 25 26 30 37 205 210 215 218 220 225 230 255 260 262 305 310 311 315 320 325 330 331 335 336 337 341 343 345 360 375 380 381

read x

do
CFNAME="$job2".chk
RFNAME="$job2".rem

cd ../$job2
put /home/salazar/chk_data/$CFNAME $CFNAME
put /home/salazar/chk_data/$RFNAME $RFNAME

done

read x

bye
!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-01-2004
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,333
Please navigate
Our Home Page -> Answers to Frequently Asked Questions -> Automate FTP / Scripting FTP Transfers
Reply With Quote
  #3 (permalink)  
Old 07-02-2004
Registered User
 

Join Date: Jul 2004
Posts: 6
I couldn't find what I needed there. Any other suggestions?
Reply With Quote
  #4 (permalink)  
Old 07-02-2004
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,333
It's a very small step from this....
Code:
#! /usr/bin/ksh

HOST=remote.host.name
USER=whoever
PASSWD=whatever

exec 4>&1
ftp -nv >&4 2>&4 |&

print -p open $HOST
print -p user $USER $PASSWD
print -p cd directory
print -p binary
print -p put tar.gz
print -p bye

wait
exit 0
to this....
Code:
#! /usr/bin/ksh

HOST=remote.host.name
USER=whoever
PASSWD=whatever

exec 4>&1
ftp -nv >&4 2>&4 |&

print -p open $HOST
print -p user $USER $PASSWD
print -p binary
for job2 in 3t 11 12 13   ; do 
      print -p cd  $job2
      CFNAME="$job2".chk
      print -p  put /home/salazar/chk_data/$CFNAME $CFNAME
done
print -p bye
wait
exit 0
That's one of the advantages that the coprocess technique has over the here-document technique.

Last edited by Perderabo; 07-28-2005 at 08:15 AM.
Reply With Quote
  #5 (permalink)  
Old 10-06-2006
Registered User
 

Join Date: Oct 2006
Posts: 1
For loop in SFTP

Could you please suggest or give a sample script to use for loops in SFTP script?
The SFTP should be in non-interactive mode.

Thanks & Regards,
Vijay
Reply With Quote
  #6 (permalink)  
Old 10-18-2007
Registered User
 

Join Date: Sep 2007
Posts: 5
Red face Recieving while forking background process

Quote:
Originally Posted by Perderabo View Post
It's a very small step from this....
Code:
#! /usr/bin/ksh

HOST=remote.host.name
USER=whoever
PASSWD=whatever

exec 4>&1
ftp -nv >&4 2>&4 |&

print -p open $HOST
print -p user $USER $PASSWD
print -p cd directory
print -p binary
print -p put tar.gz
print -p bye

wait
exit 0
to this....
Code:
#! /usr/bin/ksh

HOST=remote.host.name
USER=whoever
PASSWD=whatever

exec 4>&1
ftp -nv >&4 2>&4 |&

print -p open $HOST
print -p user $USER $PASSWD
print -p binary
for job2 in 3t 11 12 13   ; do 
      print -p cd  $job2
      CFNAME="$job2".chk
      print -p  put /home/salazar/chk_data/$CFNAME $CFNAME
done
print -p bye
wait
exit 0
That's one of the advantages that the coprocess technique has over the here-document technique.

Hi Perderabo,

i am recieving the following error message while executing the above snippet of code.

could you advice what should i do to avoid the below error


test3: line 25: syntax error near unexpected token `&'
test3: line 25: `ftp -nv >&4 2>&4 | &'
Reply With Quote
  #7 (permalink)  
Old 10-21-2007
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,333
Quote:
Originally Posted by harim View Post
Hi Perderabo,

i am recieving the following error message while executing the above snippet of code.

could you advice what should i do to avoid the below error


test3: line 25: syntax error near unexpected token `&'
test3: line 25: `ftp -nv >&4 2>&4 | &'

Cut and paste if you can't get the syntax right. There is no space between the | and the & in my code. You added a space between them.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:55 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0