Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

move a file from one server to another server using a batch file

Posted on 2012-04-06
8
Medium Priority
?
364 Views
Last Modified: 2012-04-10
Can anyone tell me how to move a file from one server to another server using a batch file?  I can move a file within the same server, but not able to move it to another server.
0
Comment
Question by:moni81011
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 17

Accepted Solution

by:
Anuroopsundd earned 1200 total points
ID: 37817094
just to simplify .. you can map the shared folder of 2nd server in your batch file then copy the file as you are doing it locally. after copy completed delete the shared folder drive

net use x: \\servername\sharename  password /USER:myAccount
copy c:\text.txt x:\
net use x: /delete
0
 
LVL 57

Expert Comment

by:Bill Prew
ID: 37817340
What have you tried that didn't work, and what was the error(s)?

~bp
0
 

Author Comment

by:moni81011
ID: 37817385
Could we do it the other way around?  Could we place this .bat file on the server the file is going to and grab the file from the server it is coming from?

Thanks in advance.
0
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 

Author Comment

by:moni81011
ID: 37817418
What Anuroopsundd told me to do works, but I'm not exactly sure how to place the .bat file on our host as that is where the file resides.  So I wanted to see if there is a way to place the .bat file on the server the file is supposed to go to and what code needs to be changed in the .bat file.
0
 
LVL 57

Expert Comment

by:Bill Prew
ID: 37817463
Should work the same way, just reverse the parms in the COPY, like:

net use x: \\servername\sharename  password /USER:myAccount
copy x:\text.txt c:\destdir
net use x: /delete

~bp
0
 

Author Comment

by:moni81011
ID: 37817633
I'm not 100% sure how to make that work.  Ok, this is what I did the first time to make it work:

I got a file from my pc and placed it on the server using what Anuroopsundd provided like this:

net use x: \\servername\sharename path (2nd server-destination server)
copy C:\Users\path\filename x:\
net use x: /delete

and that works.

Now I want to be able to put the .bat file on the second server where the file should end up at and tell it to go to the host and grab this file and put it on this server.
If I just reverse the second line where it is copying the information, it is looking for the file on the second server, which it will never find cause it resides on the first server.
Do I make any sense? I hope I do.  :)
0
 
LVL 57

Assisted Solution

by:Bill Prew
Bill Prew earned 300 total points
ID: 37817923
In the BAT file you put on the 2nd server, you will still specify the path from the first server in the line:

net use x: \\servername\sharename path

~bp
0
 

Author Comment

by:moni81011
ID: 37828569
Thank you.  I tried that, but for some reason it does not work.  
Thank you for all your help.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question