Using sftp from one server to other server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using sftp from one server to other server
# 22  
Old 09-07-2011
The script that you require is only one line long.
The only thing that will make it longer, is if the user_id is variable, or you want to test for success or failure of the copy.
The input to the script is two lines long.
This can be literals unless the file name(s) are variable
If you use sftp and not scp, then you must configure ssh to use stored keys instead of passwords if you wish to run the script unattended (background, or as a scheduled task).
Since you are unfamiliar with unix, why don't you push the file from the mainframe to the unix system, then all you need to know about unix is the destination file name and directory, and a valid userid and password, with write permissions to the destination directory.
# 23  
Old 09-07-2011
Quote:
Originally Posted by jgt
why don't you push the file from the mainframe to the unix system, then all you need to know about unix is the destination file name and directory, and a valid userid and password, with write permissions to the destination directory.
thank you i will try using stored keys and configure ssh because i need to create an automated script

you mentioned about pushing the file from mainframe to unix system how to do that i need just the logic

---------- Post updated at 05:22 PM ---------- Previous update was at 05:08 PM ----------

Quote:
Originally Posted by Corona688
Which files, from where, should end up where? You already have lots and lots of them, stop begging for more. You just don't have the paths you need to use them.


DONT TALK TO MUCH IF U WISH TO ANSWERE ON MY QUESTION THEN DO IT OR ELSE LEAVE IT IF I START TALKING U WONT BE ABLE OPEN UR MOUTH Smilie

Quote:
Originally Posted by
That script of yours isn't much help. There's no UNIX file paths in there. Maybe there's more in whatever system was running that program, since I doubt it ran itself -- it seems to have depended on something larger. That only might be the file name, it seems dubious. It certainly doesn't tell you or us [U
where[/U] it is. Sorry.

Do you have shell access to the computer in question? Can you ssh in in a terminal, and try to find the file from there?
FORGET ABOUT MY SCRIPT WHATEVER I GAVE LEAVE IT

YOU TOLD TO USE SCP I WANTED TO KNOW AS THE FILE WHICH HAS TO BE TRANSFERRED TO MY UNIX SERVER EXISTS IN MAINFRAMES SERVER.

So will scp work for file transfer between mainframe and unix server
# 24  
Old 09-07-2011
Quote:
Originally Posted by msandeep27
DONT TALK TO MUCH IF U WISH TO ANSWERE ON MY QUESTION THEN DO IT
As the last 4 pages of discussion has been trying to tell you -- we need information from you to do that. Sure, I can ignore your script, and have nothing to go on at all...

You've got examples good enough for you to plug in the filename and go. If you want us to do that, we need to know it. You don't know where the file actually is anyway and I can't tell you, because my crystal ball has been stuck in maintenance for years.

Once you do, it's a simple matter of copy-pasting it into one of the things given to you in this thread, vi myprogram ; chmod +x myprogram ; ./myprogram.

Quote:
So will scp work for file transfer between mainframe and unix server
If you know that sftp will, then of course it will: They use the exact same protocol. They talk to the same daemon.

Do you know that sftp will work? This might be a wild goose chase -- we have no idea what your mainframe is. It might be something strange, by the sound of it. Have you tried from a terminal, for instance?

We don't know what your UNIX is, for that matter! Both would let us write more complete/working examples.

If you know for a fact that sftp will work, then we're nearly done. You can just put it into one of the examples given and do it.

---------- Post updated at 04:46 PM ---------- Previous update was at 04:28 PM ----------

Here is as complete an example as can be written without knowing what your systems are. It might not be quite right, but I get the feeling I might be heading home sooner than I can find out what you haven't told us yet.

1) Create a file. If you have vi, 'vi filename'. If you have nano, 'nano filename'. If you have emacs, 'emacs filename'. If you have pico, 'pico filename'. And so forth. We don't know your system or text editor yet.

2) The file should look like this:
Code:
#!/bin/sh
# Replace /path/to/remote/file with whatever your remote file actually is.
sftp username@host <<EOF
get /path/to/remote/file
EOF

3) Set it executable: chmod +x ./myprogram
4)Run it: ./myprogram
5) Tell us if it didn't work: In detail, not "IT DIDNT WORK".

Last edited by Corona688; 09-07-2011 at 07:37 PM..
# 25  
Old 09-07-2011
Quote:
Originally Posted by Corona688
As the last 4 pages of discussion has been trying to tell you -- we need information from you to do that. You don't know where the file actually is and I can't tell you, because my crystal ball has been stuck in maintenance for years.

Once you do, it's a simple matter of copy-pasting it into one of the things given to you in this thread, chmod +x, ./myprogram.

If you know that sftp will, then of course it will: They use the exact same protocol. They talk to the same daemon.

Do you know that sftp will work? This might be a wild goose chase -- we have no idea what your mainframe is. It might be something strange, by the sound of it. Have you tried from a terminal, for instance?

If you know for a fact that sftp will work, then we're nearly done. You can just put it into one of the examples given and do it.
ANSWERE1 :SmilieTHE FILE EXISTS IN THE MAINFRAME SERVER IN THE FOLLOWING LOCATION

CAM.NC.CUR(0)
if this too does not help let me know as i cant give you the orginal path because of security reasons so try to understand


ANSWERE 2:YES I KNOW 100% THAT SFTP CAN BE USED TO DO THE TRANSFER FILE .
CAN YOU TELL ME HOW TO CREATE A BATCH JOB BY USING YOUR SCP COMMAND

---------- Post updated at 05:52 PM ---------- Previous update was at 05:49 PM ----------

I FOUND SOME INFORMATION ON THIS I SHARING THE LINK PLEASE TELL ME IF THIS WILL WORK
https://libsys.kctcs.edu/stapleton/f...scripting.html
# 26  
Old 09-07-2011
Please stop screaming at folks. You're supposed to be some sort of professional, yes?

Lots and lots and lots of questions in my last post you didn't answer. What kind of computer you're using is hardly proprietary information...

Quote:
Originally Posted by msandeep27
ANSWERE1 :SmilieTHE FILE EXISTS IN THE MAINFRAME SERVER IN THE FOLLOWING LOCATION

CAM.NC.CUR(0)
That's not any sort of file path that I recognize. But if you say so. Go ahead and try it.
Quote:
if this too does not help let me know as i cant give you the orginal path because of security reasons so try to understand
There's other things you could've answered that wouldn't have given away proprietary information. Like, what kind of system that mainframe is. 'CAM.NC.CUR(0)' makes no sense in UNIX, and probably won't make any sense to SFTP, but knowing what the system is may help us figure out what it actually means.

Furthermore. I ask whether you're positive you know sftp works, not because I think you're an idiot, and not because I like the rush of wind of you screaming at me for having the temerity to ask an obvious question, but because in threads about mainframe systems before, they've often used ftps, not sftp. Not the same thing at all.

I can only hope you missed the update I added and aren't actually asking me to feed the example to you keystroke by keystroke...
# 27  
Old 09-08-2011
Quote:
Originally Posted by Corona688
Here is as complete an example as can be written without knowing what your systems are. It might not be quite right, but I get the feeling I might be heading home sooner than I can find out what you haven't told us yet.

1) Create a file. If you have vi, 'vi filename'. If you have nano, 'nano filename'. If you have emacs, 'emacs filename'. If you have pico, 'pico filename'. And so forth. We don't know your system or text editor yet.

2) The file should look like this:
Code:
#!/bin/sh
# Replace /path/to/remote/file with whatever your remote file actually is.
sftp username@host <<EOF
get /path/to/remote/file
EOF

3) Set it executable: chmod +x ./myprogram
4)Run it: ./myprogram
5) Tell us if it didn't work: In detail, not "IT DIDNT WORK".
you code worked for me thanks a lot
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Needed SFTP script from windows to UNIX server and from UNIX to windows server(reverse SFTP)

hi guys, i need a script to sftp the file from windows to unix server ....(before that i have to check whether the file exists in the windows server or not and again i have to reverse sftp the files from unix to windows server..... regards, Vasa Saikumar. (13 Replies)
Discussion started by: hemanthsaikumar
13 Replies

2. Solaris

Script to get files from remote server to local server through sftp without prompting for password

Hi, I am trying to automate the process of fetching files from remote server to local server through sftp. I have the username and password for the remote solaris server. But I need to give password manually everytime i run the script. Can anyone help me in automating the script such that it... (3 Replies)
Discussion started by: ssk250
3 Replies

3. Shell Programming and Scripting

Sftp script for dev server to client server

hi, i am new to unix, cuold u send some sftp acripts to send files to dev server to clint server, (1 Reply)
Discussion started by: Koti.annam
1 Replies

4. Shell Programming and Scripting

Sftp some files from windows server to UNIX server

hi i need to transfer some files from windows server to unix server using SFTP. but before transferring the files, i need to check the existence of a particular file in the remote directory (say r_dir1). if the file is present, then SFTP all the files. after SFTPing the files from the remote... (1 Reply)
Discussion started by: vinit raj
1 Replies

5. Shell Programming and Scripting

Need Help on SFTP login from another server

Hi Experts, I am writing one shell script. Below is the requirement 1. need to login to the SFTP server, go to the particular folder 2. take the file count in that folder and assign it to variable 3. came out of the SFTP server and check the condition, if the file count is less than the... (1 Reply)
Discussion started by: bbc17484
1 Replies

6. UNIX for Dummies Questions & Answers

sftp connection to the same server(from same server)

Hi, After logging in to a server, Can I open a new sftp connection to the same server from the same server itself. Does it have any connection issues/limitations for ports etc. and can I copy/move files using the new sftp connection in the same server. Do we have any limitations of opening new... (1 Reply)
Discussion started by: Mathews567
1 Replies

7. Shell Programming and Scripting

sftp within a server

Hi, I have configured keygen-ssh settings on my remote server and from putty also now I log on from my machine through putty to remote server and it is pass wordless authentication , Now I have a small sftp script that transfer text files from one folder to another folder within that server... (4 Replies)
Discussion started by: rahulsxn660
4 Replies

8. Cybersecurity

Using sftp from mainframes to other server

HI all I need a script that would take the file from a mainframe to another server.Presently i am using a ndm but i am not knowing what the changes would be required to change to sftp. Can you please provide some code that would be helpful Thanks (7 Replies)
Discussion started by: msandeep27
7 Replies

9. Programming

SFTP from one remote server to another remote server from desktop

Hi, I have 1. lappy 2. server A 3. server B Now, what i need is to run a command from lappy that will sftp a file from server A to server B. Please guide me to achieve this. -akash (1 Reply)
Discussion started by: akash.mahakode
1 Replies

10. Solaris

i want to sftp to a server

Hi all, I want to sftp to a server called serverB. I want to do it via a running a script. The code i have written is that.. sftp -v x.x.x.x << EOF user username password cd dir1 bin mget * bye EOF But it is not at all working and even it is asking for... (2 Replies)
Discussion started by: naree
2 Replies
Login or Register to Ask a Question