[SOLVED] BAT script to copy files and run anther bat script?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
BAT script to copy files and run anther bat script?
Hi
I would appreciate if anyone here can help me with this? this is for my work and I am a bit stuck about how to do this.
My team asked me if I can do a bat script to do the following:
1. connect to server from server1 to server2
2. copy 2 files from server 2 to server 1
3. run the bat script from server 1
(bat script then uploads these 2 copied files) this bat script is already done.
you gave almost no information, so we can hardly give you any help:
what kind of connection is it?
what kind of os is running on server, server1 and server2?
how do you want to transfer your files (over share, ftp, scp, rsync ...)?
...
Perhaps. Must we guess what operating systems and what kinds of machines are involved? Is there a TCP network connection between the machines? Is there any special software installed that might either interfere or support this operation? What have you researched or tried before posting the question here?
You might browse the information about asking intelligent questions, available on this site.
you gave almost no information, so we can hardly give you any help:
what kind of connection is it?
what kind of os is running on server, server1 and server2?
how do you want to transfer your files (over share, ftp, scp, rsync ...)?
...
You sure this thing is SFTP? I would think it is "File and printer sharing", a part of Microsoft networking,
Yes the company I work at everything is SFTP and SSL etc part of PCI Compliant.
This script works below but only within the same server. Not sure how to edit this to work from
CONNECT SFTP SERVER 1 to SERVER 2
COPY SERVER 2 file to SERVER 1 (SFTP) connection
Code:
set path=c:\WINDOWS\system32
echo Copying started at %date% %time%>>_date_.txt
xcopy \\172.10.10.2\c$\Test\test1.xml \\172.20.10.2\c$\temp /s /a /d
echo Copying finished at %date% %time%>>_date_.txt
echo Completed Successfully at %date% %time%>>_date_.txt
echo --------------------------------------------------------------------------- >>_date_.txt
CALL "\\172.20.10.2\c$\Test\foo.bat"
echo Uploaded Successfully at %date% %time%>>_date_.txt
pause
You can use xcopy to copy a file to a remote computer. xcopy does use Microsoft file sharing (CIFS)
To copy a file from server1 to server2 via xcopy.
Code:
net use \\server2\shared_folder password /user:domain\username
xcopy file1.txt \\server2\shared_Folder\file1.txt
net use "\\server2\Shared_Folder" /delete
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.