Can't transfer files using FTP script and batch on Windows - 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.

Related

Ftp Windows Command Line Command Not Working

I'm using Windows command line for getting some files from a ftp server.
I need to change the local directory during the session.
I tried using 'lcd' command but it's not working. I displayed that the command is executed correctly but when i download the files they are downloaded on another directory (default?).
Retyping 'lcd' to show the actual local directory i can see it does not change.
The code i used is written below
lcd C:\Myfolder\MySubFolder
I tryed also the cmd with administrative priviledges, but it is the same.
Thank You.

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!

Implicit TLS FTP connection using WinSCP or other command line FTP client in Windows

I need to connect to an FTP secured with implicit TLS, username and password from the command line so that I can create a batch later on. I am using WinSCP since it's the most popular (I think) or the one that I can use to achieve this according to extensive googling. I'm not an expert but reading the documentation I have this so far with unsuccessful connection from command prompt:
winscp> open username:password#host:port -implicit -certificate="aa:aa:aa:aa..."
Once connected I need to extract everything there to a folder \hostname\folder or c:\folder then delete the files on the ftp (more or less like cut)
Thanks to Martin Prikryl correction I was able to connect, here is what I did:
Created a text file with the winscp.com commands "connection.txt":
# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect with username and password
open ftp://username:password#host:port -implicit -certificate="aa:aa:aa:aa...."
# Change local directory
lcd C:\local_working_folder
# Force binary mode transfer
option transfer binary
# Download missing files to local directory from remote
synchronize local
# Delete all remote files
rm *
# Disconnect
close
# Exit WinSCP
exit
Now from command prompt or in a batch file you just call winscp.exe from where it is installed. If from installation media it should be C:\Program Files\WinSCP\WinSCP.exe of if extracted from a .zip portable version point to the folder where you extracted the file:
C:\WinSCP\WinSCP.exe /console /script="connection.txt" /log="conn.log"
Then just schedule the batch to automate the process.
Your syntax is almost correct. You are missing only the protocol prefix ftp:// (note that WinSCP defaults to the SFTP protocol).
open ftp://username:password#host:port -implicit -certificate="aa:aa:aa:aa..."
For details see:
https://winscp.net/eng/docs/session_url
https://winscp.net/eng/docs/scriptcommand_open
If that does not help, you need to share with us a script log file or at least an error message.

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

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.

Resources