Batch file not executing in server - batch-file

I have been running a batch file to copy files from one location (my local machine) to multiple servers. Recently we moved into a server for processing files, now the problem is the same batch file is not working when I copy it from one server to another 2 or more servers....
Do I have to change any statements in the batch file pertaining to servers...?
Here is my batch file:
#echo off
echo copying files to multiple servers
copy *.eps* \\server1\adman\in\displ
copy *.eps* \\server2\BasketsIn\TheHindu\AdImport\Ads_SAP))

This will copy a static filemask of files from one server to two other servers.
You need read/write permissions over the lan.
#echo off
echo copying files to multiple servers
set "source_server=\\server0\c\share"
copy "%source_server%\*.eps*" "\\server1\adman\in\displ"
copy "%source_server%\*.eps*" "\\server2\BasketsIn\TheHindu\AdImport\Ads_SAP"

Related

How to Copy files in FTP path

i have FTP created inside Default FTP Site on one server name A and trying to copy files from other server B and trying to place in Server C through batch script, which is configured in A as physical path, i can see transfer is happening but its going in root folder of A which is not correct. Please suggest me what code i need to write in batch script which can place file on sever c.
If you want to keep directory structure, you can compress to zip with directories and unzip at target. This may also reduce file transfer load. But if you wanna make it one by one, in the batch file, store full path and check full path at target. At target, create full path and copy file if path exists.

How to avoid automatically repeating files in SSIS foreach loop if files come from FTP server

I have FTP server where people put some txt files that I need to process. I have for each loop for FTP task and with that, i receive a file to local directory from FTP server. Next, I need to process files from the directory in the foreach loop, and my question is can I somehow protect my loop to don't iterate through the files from past.
Example: someone put files on FTP yesterday. I process them and they are in my local directory. Today someone put a file on FTP, FTP task download them to the local directory and my loop will iterate through all files, yesterday and today. How can I avoid this, without deleting them manually

where is my batch file?

I made several bat files using task scheduler(custom) and I need to apply these to all of my 70 server computers. Obviously I don't want to repeat the same procedure at every server.
Can I simply copy and paste my bat files to different computers and expect same result?
If so, where are my bat files and where should I paste them?
Simply copy your batch files to different servers.
This post here shows location of task scheduler.
Folder location:
%systemroot%\System32\Tasks
Registry:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Schedule\Taskcache\Tasks
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Schedule\Taskcache\Tree
You may want to try the xcopy and for command to send your batch file to all servers.
Command syntax:
FOR command can loop through your server names, and XCOPY copys the batch script to the other servers.
for %%G in (serverA
serverB
serverC
...
serverZ) do xcopy [source] [destination] [options]
Note that asterisks does not work as intended, since it works as a wildcard.

Batch file runs on local desktop but not on file server

I am new to .bat files but have been working on a process for two days. It is very simple and works fine on my desktop (thanks for a code snippet found on the internet), but when I try to run it through a shared drive on our file server, the processing does not occur.
#echo off
REM Batch file to process daily flat file and replace " with empty space for upload into Access/SQL Server
ren C:\Users\Desktop\filejuly17.txt filequotes.txt
for /f "tokens=* delims= " %%a in (C:\Users\Desktop\filequotes.txt) do (
set S=%%a
set S=!S:"=!
>> C:\Users\Desktop\finalfile.txt echo.!S!
)
I have had to switch the ren to a copy on the file server, but have verified that I can copy the one file to another using that process. So am assured that I have the path correctly. However, no matter which options I have tried, I am unable to have this batch file strip out the double quotes that are randomly in the file from user entry. We need to strip these out and replace them with empty spaces in order to have a data migration process then load this flat file into our database.
Thank you for any guidance.
If it helps, my laptop is running on Windows 7, the server I remote connect is running on Windows Server 2008.

Batch file when using WinSCP and command prompt

I am currently writing a script that calls WinSCP, connects an SFTP session, transfers a group of files from a local server to a remote server, closes the connection, then moves the local file to an archive. An alternate acceptable solution would be to copy the file to archive and then delete it from the source directory.
The problem I am having is that I can get WinSCP to open, connect and transfer the files, but after that the commands are ignored and I am unable to automate the connection close, file move or copy and the deletion and closing of command prompt. What is the best way to do this?
My FTP.bat file that connects the session and calls the script -
"C:\Program Files\WinSCP\WinSCP.exe" /console /command "lcd d:\bofa_ftp\out" /script=script.txt savedsession#winscpname.com
My script file that puts the file and closes the connection -
option batch abort
option confirm off
option exclude script.txt
put *.txt
close
When I add any commands to either the bat or the script they are ignored.
Commands after close are definitely not ignored. Your problem might be that you are trying to put Windows commands to WinSCP script. Note that there are no commands in WinSCP to move local files.
Instead of trying using Winscp3, try with plink.exe.
Plink is the best option to transfer files from winscp3 to your local.By using scp command we can transfer file from winscp to local as well as one folder in to another folder in winscp.
scp username#atechguideserver1.com:/data/tmp/samplscp.txt username#atechguideserver2.com:/data/tmp/dir/tech
Please refer to: http://99students.com/move-files-in-unix/

Resources