Using sftp from one server 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

What is the type of other server ( not the mainframe )?.
If you intend to move the files from the mainframe to some other host that is running some UNIX variants, Then easily you can write some shell script to initiate a connection to the mainframe over SFTP then pull out files to the other host that would be easier as majority of forum members never been exposed to mainframes.
Anyways what type of mainframe OS is this sever?

1 Like

Actually my file is present in the main frame server and i need to get that file to my unix server.so i am asked to write a script using sftp instead of ndm . As i am totally new to unix so i am not getting actaully how to start can you please help me by telling what would be the script i have already given the script i used when i had to use ndm so now we need to change to sftp.
please reply me as soon as possible i need this very urgently

Thanks

---------- Post updated at 11:37 AM ---------- Previous update was at 11:26 AM ----------

someone please help me out i need this script as soon as possible

Why not just use scp on the command line (for one file)? If you have sftp, you probably have scp installed... "man scp" should help.

Which machines have sftp servers, and which have sftp clients.
If you have the client software for the mainframe it will likely be easier to push the file the the unix system.
To run it from the unix side, once you have a connection is simply:

$sftp mainframe
sftp>get gh.ij.kl(0) /u/scripts/mn
sftp>quit
$

Is the source file ASCII or EBCDIC ?
What record separator(s) does the source file use?

1 Like

we cant use scp command because we need to write a script not a command to get those files

---------- Post updated at 11:53 AM ---------- Previous update was at 11:48 AM ----------

Hi jgt thanks for you reply

this is a unix script that we are using to ndm the file form the mainframe server to the unix server.i have confirmed from the mainframe people if we can use sftp to get those files and they confirmed me that i can use sftp to get those files. but for that i need to write a script as i am totally new to unix i am not at all write the code

the code you mentioned were are you passing the username and password to the mainframe server can you please give me the full script ??

it would be very helpful for me

That doesn't make any sense. You can use scp in a script.

scp username@host:/path/to/remote/source /path/to/local/dest
scp path/to/local/source username@host:/path/to/remote/dest

as far i know scp is just a command that is run is unix directly if we can use it in the script can you please tell the me the full script i have no knowledge of unix so i am not able to code this at all .

Thanks

They're all just commands.

Some, like text editors, will sensibly demand a terminal to work of course, but it's not a different "kind" of command.

There's no direct translation that I can see. I can't even tell what the filenames are supposed to be in that thing. I've given you complete examples of copying from remote-to-host and host-to-remote, clearly labelled, for you to modify to your own needs. What more can I do?

scp on its own will demand a password. If this is unacceptable, you can set up keys in advance to let the process happen without interaction. Google 'passwordless ssh' to find out all about how.

acutally i dont need any commond to run from command prompt but what my client needs is a a shell script which i am not knowing how to write so help me out with the shell script using sftp to get those files please i would be very thank ful to you .i given almost all the information that i can just provide me the shell script

To use sftp in batch mode, you must first set up password-less authentication.
Then

sftp -b user@mainframe <<EOF
get file /u/scripts/file
quit
EOF

or
create a file called input.data

get file /u/script/file
quit

and call "sftp -b user@mainframe input.data
If you cannot set up password-less authentication, you may be able to solve the issue by having an intermediate MS Windows machine running Winscp3 http://winscp.net

so it that file you want me to mention the username and password and then after it gets connected to the mainframe server i should use get and get the file i want form that location to the usix server .
correct me if i am wrong???/

scp runs in shell scripts just as well as sftp, you're confusing the issue. It even uses the same protocol as sftp.

I've given you complete examples of copying from remote-to-host and host-to-remote, clearly labelled, for you to modify to your own needs, which you will need to do because your original script is cryptic and vague, possibly missing context, not something easily translated. If you know what files need to go where, putting in your paths instead of mine is not difficult. If you have any questions more specific than "please do everything for me" I'm listening.

you can use FTP to get file from mainframe

Automated script to look for files in FTP Server location.

hi jville

i edited few things in the example you provided please correct me if i am wrong somewhere

@Corona688
I think he wants a script to automate the file transfer process , So he needs a shell script to pull out the files from the mainframe.

1 Like

Thanks

yes exactly this is what i need i need to automate the file transfer by using sftp for that i need the script

Obviously. He's been given four separate usable answers to that question too, as well as plausible alternatives if sftp/scp can't work for him.

But he keeps demanding script code instead of shell code as if they're not the exact same thing, as if sftp is a special "script program" :wall: "script" code is just "shell" code put in a text file and set executable!

If there's anything more about what he expects the script to do, it's not clear at this point. The program he posted looks like a part of something larger, and isn't too informative in itself. He hasn't even told us what paths and filenames he wants transferred, whether it's one or many, whether it's always the same or should find the files or what.

---------- Post updated at 02:49 PM ---------- Previous update was at 02:48 PM ----------

You have them. Several of them. If they're insufficient, in what manner are they insufficient?

---------- Post updated at 02:54 PM ---------- Previous update was at 02:49 PM ----------

You cannot embed a password for sftp. If you want it to work noninteractively, you have to use ssh keys. To tell you how to do that we need to know more about your system(s).

@Corona688
Pardon me if I didn't get you correctly , but as he said earlier he is new comer to UNIX world so messing with acronym won't be a big problem in such situations.
Anyways his script is part from longer script.

@msandeep27
Provide us the full path to your files , So we can rewrite the script provided above

See i am not knowing what more information you want from me . i am posting the entire code only not from the middle

---------- Post updated at 02:49 PM ---------- Previous update was at 02:48 PM ----------

[quote
you have them. several of them. if they're insufficient, in what manner are they insufficient?.[/quote]

See everyone is providing bits of code i have already told that i totally new to unix how do you expect me to frame all those so only i am asking a sample script atleast to do so .

---------- Post updated at 02:54 PM ---------- Previous update was at 02:49 PM ----------

[quote
you cannot embed a password for sftp. if you want it to work noninteractively, you have to use ssh keys. to tell you how to do that we need to know more about your system(s).[/quote]

what information you want from me about the systems please do ask

I JUST NEED AN EXAMPLE OF AN AUTOMATED SCRIPT IN WHICH SFTP FILE TRANSFER IS DONE THAT IS ALL I NEED

---------- Post updated at 04:18 PM ---------- Previous update was at 04:13 PM ----------

the path where the file exists in the main frame server is
imp.file.file(0)
let me know if you need any more information