Remote copy command?

Advertisement

stevec5088
Joined:
Posts:
2
Location:
WhitneyZone.com

Remote copy command?

I need to streamline an automated WinSCP session, where the session connects to the remote server, and copies one file over another. It is similar to the mv command, but I don't want to destroy the original file.

I've tried issuing:
call cp file1 file2
but that returns the error:
500 CP not understood
Note the CP is changed to uppercase.

It appears the interactive WinSCP process has a "duplicate" process, but I cannot seem to find a way to remotely make a copy of a file using a batch script.

I sure hope someone can help. I will appreciate the help.

Reply with quote E-mail

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Re: remote copy command?

I do not think FTP has command to duplicate remote file.
In GUI with FTP protocol, WinSCP duplicates the remote file via temporary local copy.

Reply with quote

stevec5088
Joined:
Posts:
2
Location:
WhitneyZone.com

Thank you, Martin, for the help.

It appears WinSCP is still working the same as FTP on the remote server, so no new capabilities... is that correct? If so, too bad.

I am not very familiar with unix, so I somehow thought the call command could be issued to run the remote cp.

What am I missing?

Reply with quote E-mail

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

stevec5088 wrote:

I am not very familiar with unix, so I somehow thought the call command could be issued to run the remote cp.
With FTP protocol the call command executes raw FTP protocol commands.
Some (but few) FTP servers have commands to execute arbitrary shell commands, such as site exec <shell_command>.
See also:
https://winscp.net/eng/docs/remote_command

Reply with quote

cprasad111
Joined:
Posts:
5
Location:
singapore

winscp from unix

I have a script in unix that I use to run task in Windows by remote invoking
eg (command written in unix):
myscript windows_IP_address "command to be executed"
eg of command to be execute: d:\\a.cmd or echo d:\\a.txt etc. and it works

Similarly I want to invoke and run WinSCP the same way and transfer file from Windows to Unix
what i tried:
$ myscript windows_IP_address 'd:\\blah\\blahWinSCP.com unix_user@unix_IP /hostkey "sh-rsa 1024 xx:xxx:xx:xx" /command put "d:\\blah\\blah\\a.txt" /tmp/blah/a.txt'
 
$ myscript windows_IP_address 'd:\\blah\\blahWinSCP.com unix_user@unix_IP -hostkey="sh-rsa 1024 xx:xxx:xx:xx" /command put "d:\\blah\\blah\\a.txt" /tmp/blah/a.txt'
 
$ myscript windows_IP_address 'd:\\blah\\blahWinSCP.com unix_user@unix_IP /privatekey "address ofprivate key" /command put "d:\\blah\\blah\\a.txt" /tmp/blah/a.txt'
i have tried all the combinations of the combinations of private key and hostkey

this works from windows:
d:\\blah\\blahWinSCP.com unix_user@unix_IP /command put "d:\\blah\\blah\\a.txt" /tmp/blah/a.txt
<<where the private key is taken from pageant; but in unix i have to provide the private key file location>>

the same syntax work for Putty, there the key is given by the token: -i "address of primary key file"

is there any way to give the address of private key file or hostkey or anything that can work

Reply with quote

Advertisement

cprasad111
Joined:
Posts:
5
Location:
singapore

call winscp from unix and how to specify private key file

....SOLVED....

after trying some permutations and combinations of the syntax given in the documentation, I was able to specify the private key file location in the command line itself. And it ran successfully. No need to specify the hostkey (atleast in my case). The code was tested while pageant of putty was off to prevent taking the private key from there.

The command was written in windows command prompt
winscp.com user@server_ip_address /command "put readme.txt /path/path1/readme.txt" /privatekey="path_of_private_key\mani.ppk"

The command was written in unix machine
my_script_to_invoke_window_jobs windwo_ip_address 'path_of_winscp.com\\WinSCP.com user@unix_ip_address /command "put path_of_file_in_windows\\r.txt /path_of_file_in_unix/t.txt" /privatekey="path_of_private_key\mani.ppk"'

Reply with quote

Advertisement

You can post new topics in this forum