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
problem with dd command or maybe AFS problem Anta Shell Programming and Scripting 0 08-25-2006 11:10 AM
SSH Problem auth problem budrito UNIX for Advanced & Expert Users 1 03-17-2004 10:12 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 06-06-2008
kdyzsa kdyzsa is offline
Registered User
  
 

Join Date: May 2008
Posts: 14
Help me please on my problem

I basically just need to transfer one file from one server to another.
So I first have to go to this server and with the user name and pass go to their directory and transfer it to another server with a diff user name and pass and paste it there.
I have this.

#!/bin/sh
HOST='directoryofserver2'
USER='yourid'
PASSWD='yourpw'
FILE='file.txt'

ftp -m $HOST >> END_SCRIPT
quote user $user
quote pass $passwd
put $file
END_SCRIPT
EXIT 0

I know I'm doing something wrong since nothing is being copied. how to solve this, help please
  #2 (permalink)  
Old 06-06-2008
sam_roy sam_roy is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 9
#!/bin/sh
HOST='directoryofserver2'
USER='yourid'
PASSWD='yourpw'
FILE='file.txt'

ftp -m $HOST >> END_SCRIPT
quote user $user
quote pass $passwd
put $file
END_SCRIPT
EXIT 0

I think you are trying to use END_SCRIPT to denote the end of the ftp stream. Then you must use '<<' and not '>>'.

Try this out and see if it helps
  #3 (permalink)  
Old 06-06-2008
zaxxon's Avatar
zaxxon zaxxon is online now Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,287
It is not >> but should be <<. If the problem is still there, post the error output please. You should have locally a file called END_SCRIPT now which you can delete.
  #4 (permalink)  
Old 06-06-2008
vguleria vguleria is offline
Registered User
  
 

Join Date: Mar 2008
Location: India(Sarkaghat)
Posts: 28
Hi,


Have used the following script for ftp automation.
Hope this'll help you.

#########################3
#!/bin/bash
USER=anonymous
PASS=redhat
ftp -i -n << END
open <IP_ADDRESS>
user $USER $PASS
cd pub
get file1.txt
bye
exit 0


Regards,
Vinod.
  #5 (permalink)  
Old 06-06-2008
nua7 nua7 is offline
Registered User
  
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 353
You can also try the scp command.Below is the general syntax for scp.

Code:
scp -p file_name <hostname>:/path/where/the/file/should/be/placed
For more details

Code:
man scp
  #6 (permalink)  
Old 06-06-2008
kdyzsa kdyzsa is offline
Registered User
  
 

Join Date: May 2008
Posts: 14
o

It's more of a problem of switching servers.

You see my script will be saved in the server hkhpdv13 under the directory of lets say dir/sample, my problem stems from transferring it to another server
let's say hkhpdv15 in that servers directory dir2/sample

should I first get the file from hkhpdv13? and save it to some file? I'm not familiar in how to switch directories inside a script
  #7 (permalink)  
Old 06-06-2008
nua7 nua7 is offline
Registered User
  
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 353
So in your case, the script can run on Server hkhpdv13.In your case scp command be:

Code:
scp -p /dir/sample/file1.txt hkhpdv15:/dir2/sample/file1.txt
If you want to switch directories based on user input,use $1 or $2 based on your input to the script.

If the servers need to be switched and if they are in a file:

Code:
for i in server.txt
do
scp -p /dir/sample/file1.txt $i:/dir2/sample/file1.txt
done

Hope this helps!

nua7
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 05:31 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