Copy a file from a Windows machine to a Linux machine

Advertisement

kmcguine
Guest

Copy a file from a Windows machine to a Linux machine

I am trying to use a command line to copy a file from a Windows machine to a Linux machine, but I can not get to file to copy to a different directory other than the home directory. The command line I am using is:
"c:\Program Files (x86)\WinSCP\winscp.exe" /command "option batch on" "option confirm off" "open userid:password@remotelinuxmachine" "put C:\Users\tuxadm\psft\pt\8.51\appserv\prcs\PSNTDEV\log_output\SQR_CNXMF017_2435611\CNXMF017_2435611*.PDF" "cd /home/psoft/psreports/devcop/" "/log=C:\Users\tuxadm\test.log" "exit"
The script works fine except that I can't copy to /home/psoft/psreports/devcop/, it copies to /home/psoft/.

Thanks,
Karen

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: copy a file from a windows machine to a linux machine

Use:
"put C:\Users\tuxadm\psft\pt\8.51\appserv\prcs\PSNTDEV\log_output\SQR_CNXMF017_2435611\CNXMF017_2435611*.PDF /home/psoft/psreports/devcop/"

Reply with quote

Guest

Re: copy a file from a windows machine to a linux machine

Thanks, I was having trouble where to place the quotes. After making your suggested change, I am still having trouble. I'd like to copy the entire directory. Can I do this? Do the wildcards work with the put command?
"put C:\Users\tuxadm\psft\pt\8.51\appserv\prcs\PSNTDEV\log_output\SQR_CNXPO404_2437814\*.* /home/psoft/psreports/devcop/"

Reply with quote

Guest

Re: copy a file from a windows machine to a linux machine

I believe the problem may be related to winscp is running under the "system" account. I need it to run under the user I am logged into the machine as.

Do you have any suggestions?
Thanks

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: copy a file from a windows machine to a linux machine

Anonymous wrote:

Thanks, I was having trouble where to place the quotes. After making your suggested change, I am still having trouble. I'd like to copy the entire directory. Can I do this? Do the wildcards work with the put command?
"put C:\Users\tuxadm\psft\pt\8.51\appserv\prcs\PSNTDEV\log_output\SQR_CNXPO404_2437814\*.* /home/psoft/psreports/devcop/"
You seem to have the command right.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: copy a file from a windows machine to a linux machine

Anonymous wrote:

I believe the problem may be related to winscp is running under the "system" account. I need it to run under the user I am logged into the machine as.

Do you have any suggestions?
Not sure what kind of suggestion you ask for.

Reply with quote

Sam12345
Guest

I got an error specifying that Host "put C" does not exist.

Hi,
This is the first time I'm using WinSCP (GUI side is awesome) but, when I have tried to use it in command line, I'm doing a silly mistake I believe. Can you please help me with it

The following is the command I'm using
winscp.com /command "open sftp://UsernameinLinuxMachine@LinuxHostname" -privatekey=C:\Users\MyName\Desktop\KeyFolder\private.ppk "put C:\DataFolder\FileToBeTransferred /users/MyLinuxUsername/Desktop/Folder1/"
I'm getting connected to the remote system in Linux but the file isn't getting transferred. I got following statements
Searching for host...
Host "put C" does not exist.
Searching for host...
Connecting to host...
Authenticating...
Using username "myname"
I would greatly appreciate your guidance here.

Thanks&Regards
Sam

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: I got an error specifying that Host "put C" does not exist.

You have the quotes wrong:

This should work:
winscp.com /command "open sftp://UsernameinLinuxMachine@LinuxHostname -privatekey=C:\Users\MyName\Desktop\KeyFolder\private.ppk" "put C:\DataFolder\FileToBeTransferred /users/MyLinuxUsername/Desktop/Folder1/"
Easiest is to have the command-line generated in GUI:
https://winscp.net/eng/docs/guide_automation#generating

Reply with quote

Advertisement

You can post new topics in this forum