windows batch file to copy a file from a server to local - windows

I would like to write a little code that copy on a local pc a file from another (a server).
Which Windows batch file function I can use to write this little batch file program, (FTP maybe?)
And also to visualize a message on my pc (the local pc)
thanks for all

Just use wget.
It can be called from your batch file and will download from HTTP and FTP.

Write SHUTDOWN -i in a note pad then save to desktop and name it anything but it must have .bat at the end and then click save and u can shutdown any computer in you server.

Related

Is their a way to synchronise a directory on a raspberry pi to a laptop using WinSCP

I want to be able to synchronize a directory between my Windows laptop and raspberry pi using WinSCP. By "synchronize" I mean if a file is created in the directory by my raspberry pi, it is automatically placed in predefined directory on my laptop.
I have already set up a WinSCP connection between these two devices.
I was following along using this tutorial https://www.youtube.com/watch?v=ndvEYOQLc4c however I reliazed that this was for an FTP server and I also could not save the .bat file or code file into the appropriate directory as it has it has an administrator lock, so I assume that the method is only for FTB servers.
Edit
I have given myself permissions to save the code files in the appropriate places, however I now receive the error
Host "lynn-vs2.cloudapp.net" does not exist.
Whenever I run the bat file:
winscp.com /script=SyncToLocalScript.txt
pause
Which in turn runs the txt file:
option batch abort
option confirm off
open sftp://sftpuser04:password123!#lynn-vs2.cloudapp.net -hostkey="ssh-ed25519 256 00:69:55:c8:a8:84:01:6d:7c:ff:9f:8c:89:b3:7d:67"
synchronize local C:\Users\****\OneDrive\Desktop\RaspPCAP /home/pi/Desktop/PCapFiles
exit
I am not sure what "lynn-vs2.cloudapp.net" is.

How to move local file to another local folder after sending to mainframe via FTP using batch command

I have a local file upload routine, via ftp, to a mainframe using a simple .BAT file, after successfully sending this file it should be moved to another local directory, how can I automate this process? In case of error could just pause script execution
I use two bat files, SEND.BAT and CONFIG.BAT, i run only the SEND.bat;
SEND.bat
ftp -s:CONFIG.bat X.X.X.X
pause
CONFIG.bat
USER
PASSWORD
CD B.A01
put \\SERVER.contoso.com\FOLDER\*.txt RETORNO(+1)
put \\SERVER.contoso.com\FOLDER\*.txt COMPROV(+1)
disconnect
bye
After successfully submitting, how could I automatically move these files to a respective local folder in case the mainframe return code is
250 send sucessfully
And if the mainframe return is
Not connected
or
Failed
just pause the command with Pause. Is it possible to send an email warning of both situations or open a website (this website already exists and will call my phone)? Using only bat commands in Windows?
Thanks for help!

Can't transfer files using FTP script and batch on Windows

I have a folder with PDF files locally on hard disk and I want to upload files from this folder to an FTP server.
So I created a batch file that should upload PDF files to the FTP server. Everything seems to work fine and the console window displays File successfully transferred, but actually no file really uploaded.
The FTP script content:
open
000.000.000.000 -- not the real ftp server ip lol
bla#nirlatpro.com
PASSWORD
mput c:\Batch\*.pdf
quit
Command window with output on running this script:
It looks like it works, but no file is actually uploaded.
What is even more strange is if I connect to FTP using GUI application and drag the files, it does work and all the files are uploaded to the server.
summary:
- It's works fine if i'm using windows explore and dragg the files.
- It's not uploading the files if i'm using cmd commands or batch script with ftp file, even if the console window displays 'File successfully transferred'
it was a permissions problem
apparently the ftp server does not allowing to copy files in to the root directory /
console window display it "Current restricted directory is / "
I too Faced a similar problem downloading a file from ftp through command line, But every time my request was rejected and my connection was not established.
After a thorough research i found the t i need to do settings in the IIS for ftp.
Steps:
1) Set your IIS Server on.
a:Goto control panel-->Programs&Features-->Turn windows Features on or off-->Internet Information Services.
b: Expand the Internet Information services-->Check FTP services-->Expand FTP Server-->FTP Service (Check it)-->press OK.
2)Open IIS Manager(win+r-->inetmgr)
a: Select FTP authentication-->Enable Anonymous Authentication or Base Authentication (as per your requirement).
b: Select FTP Authorization-->Select All users, give permissions (read or write or both) & press ok.
c) Open FTP Directory Browsing select MS-DOS for windows Server or Unix for Unix server.
3) Finally goto Services.msc(win+r-->'services.msc')-->MicrosoftFTPServices-->restart.
Now goto your command prompt and write your respective code for ftp it will work.

Download files from Unix server using WinSCP with get command

I have program in Unix that generates files 8 files at 8:30 pm everyday.
I need to download the files into my Windows machine after the files are generated using WinSCP.
I can drag and drop those but its time consuming, I need to automate this process.
I cannot use .Net assembly to download those.
I have tried to use the get command, but its throwing error: Not an SCCS file.
Let me know how can I solve this.
--Thanks
To automate a task using WinSCP, use its scripting interface from a batch file (e.g. download.bat).
I assume you want to use SFTP, as you are connecting to a *nix server.
The simplest download batch file is like:
winscp.com /log=c:\path\to\log\winscp.log /command ^
"open sftp://username:password#example.com/ -hostkey=""xxx""" ^
"get /path/to/file.ext c:\path\to\download\to\" ^
"exit"
Replace the username, password and example.com with the actual connection details. Get the value of -hostkey switch from your GUI session. Use real paths.
Though it's easier to have WinSCP generate the batch file for you.
For details see a guide to automating file transfers from SFTP server using WinSCP.
Once you have the batch file working, schedule the the batch file execution using Windows scheduler.
See a guide to scheduling file transfers from SFTP server.

How to copy the file from one windows machine to another windows machine in a particular drive using batch script?

In my windows server, am taking SQL DB backup in C drive. I wants to copy this .bak file to some other client windows machine in a particular drive with the current date using batch script. So that i can schedule this batch script using scheduled task. please help me out.
Can anyone, give a script to run this. thanks
Batch files are always tricky to get just right. First I'd open a command line and see if you can copy between two machines using the following syntax:
copy C:\localfile.bak \\remotemachine\c$\Path\remotefile.bak
(where "remotemachine" is the name of the remote machine and "c$" is the drive you wish to copy to). You can then copy this into a batch file and set up a scheduled task.
As for renaming the file to have the current date and time, I suggest you start with this question as it may involve some effort to get it into a format you want.

Resources