Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

End of the process signal, SFTP automation

Status
Not open for further replies.

60562

Programmer
Jul 8, 2002
2
CA
Hello gurus,
I need to write a script to exchange the data between two
databases on separate servers:
This shell should :
(1)-SFTP data file from server A to server B
(2)-run the process to read data file and update database
on server B
(3)-run the extracting process on server B
(4)-SFTP the output from server B to server A

I don't know how to recognize when step (2) and (3) will
finish executing. I am also having trouble automating SFTP,
it is always prompring for a password.

Thank you for your help!
 
scp is probably more suited to being run non-interactively than sftp.

Use the -v switch to find out why the authentication is failing and requiring a password. Have you set up a public and private key pair?

You could control the process from server A by running all the commands from there:

[tt]scp inputfile serverB:/somedir
ssh serverB "/command/to/process/file"
ssh serverB "/command/to/extract/data"
scp serverB:/somedir/extractedfile /localdir[/tt]

Annihilannic.
 
Thank you, Annihilannic!
I'd have to find out about the key generation,
is this the one when I run 'ssh-keygen'?
When I create a $HOME/.SSH/id_rsa file - the $HOME variable is for the user from 'username@sftp.company.com'? but if I was asked by other company to use the username that does not
have an account in our system what $HOME will correspond to?

I'd have to go through the process,and send the publick
key to that company that owns another server.

If we will decide to use 'sftp -B batch_file', then
the file should look something like:
open username@sftp.comany.com
binary
cd /somedir
get file.lis
bye

The batch file should have at lease 644 securliy?
Thank you for your help!
 
Since you're connecting to them, they should probably generate the private and public key pair, and give you the public key. They would have to store the private key in the .ssh directory for the user on their system, as well as adding the public key to the .ssh/authorized_keys file.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top