[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

Copying a file from a Windows server to a Linux server from the Windows command line

I need to copy a file from a Windows Server 2003 web server to a linux server.  I will be doing this from a VB program, but I thought I would just launch some command line statements.  I'm thinking of using winscp.  I've tried to do a copy command like this...

winscp ptest.script root:password@myserver.local home/scripts/ptest.script

The problem is that I don't know how to specify the file on the Windows server (which is where the command is being issued.  Since I'm on running the command on the server and I'm logged in, I'm thinking I don't need to specify a username and password.  Also, if there is a better utility to use to copy this file, I'm all ears.  The file is on a Windows web server so maybe there is an easier way to push it to the Linux server.  It doesn't necessarily need to be done at the command line, but it does need to be something I can put into my VB program.  In other words, I know I can transfer the file easily using WinSCP from the GUI, but I can't automate that within my VB program.

Thanks for the help!
0
bpl5000
Asked:
bpl5000
  • 4
  • 4
  • 2
  • +1
4 Solutions
 
ygouthamCommented:
if you can run or access the linux box over the samba share then all you need to do is mount the share as a local drive on the windows machine and then copy it on to Z: or whatever you have mounted it to be.
0
 
ygouthamCommented:
if you want to copy FROM windows TO linux, why not think about more options like FTP as well
0
 
ygouthamCommented:
if it is on a windows web server then you can copy it into the linux box by running a command on the linux box

wget http://ip.address.of.windows_box/some/directory/somefile.ext

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
bpl5000Author Commented:
This is a VMware ESX server and I'd rather not setup a samba share on it.  Since I can copy the file using WinSCP in GUI mode, I'm sure there must be an easy way to automate this.
0
 
bpl5000Author Commented:
I tired wget, but it says "command not found".
0
 
ygouthamCommented:
wget is a linux command
0
 
omarfaridCommented:
Hi,

If you can ftp to the linux server, then try the following:

cd c:\mylocaldir
ftp -s:c:\myftpcommands.txt

Where myftpcommands.txt file contains :

myremoteusername
myremotepassword
binary
prompt n
cd /to/my/remote/dir
put myfile
quit
0
 
bpl5000Author Commented:
I tried opening a ftp connect to the Linux (ESX) server and it failed.  I would rather not be transferring the password over an unsecured connection anyway.  Would there be a way to do this using WinSCP or maybe SCP? I can do it from the command line by typing the following...

winscp
open
nameOfServer
username
password
put d:\esxupdate\readme.txt /home/scripts/readme.txt

And this did transfer the file.  Anyway that I could do this from my VB program?  I can't see any command line options for WinSCP to copy a file except maybe this...

winscp.com [session] /synchronize [local_directory] [remote_directory] [/defaults]

I tried this...
winscp.com root:password@myserver.local /synchronize d:/esxupdates/updates /home/scripts/updates

It didn't work and left me at the winscp prompt (and I had to type exit to get out).  It didn't give me any error and it did open a connection, but it didn't sync the folders.  Anyway to automate this without putting a password into a text file?

0
 
Duncan RoeSoftware DeveloperCommented:
What about a VMWare share? Then you could write the file from linux
0
 
Duncan RoeSoftware DeveloperCommented:
... or read the file. Not available from the Windows command line though, only linux (guest OS)
0
 
bpl5000Author Commented:
I did find a way using WinSCP and it can be done with Putty, but you need to pull the file over from the Linux machine instead of pushing it over from the Windows machine.  A VMware share might be a good solution too... I'll have to look at that later.  Here's how to do it with WinSCP:

winscp.com root:password@10.0.0.15 /command "put d:\esxupdates\filename.script /home/scripts/filename.script"
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now