Before scheduling script it is worth to check how it works. so from Command Prompt I have just run my batch file.
The server rejected SFTP connection, but it listens for FTP
connections. Did you want to use FTP protocol instead of SFTP? Prefer
using encryption.
Image:
As shown in the image above, I have specified that It is FTP file protocol. But It doesn't help.
So far I have looked up:
https://winscp.net/eng/docs/message_server_rejected_sftp_listens_for_ftp
https://winscp.net/eng/docs/ui_login
And It works fine on FileZilla as FTP. Therefore, I can eliminate the following possibilities:
Server unexpectedly closed network connection;
Network error: Connection refused;
Network error: Connection reset by peer;
Network error: Connection timed out.
And here is my .bat for reference:
C:\Program Files (x86)\winSCP\winSCP.com" /script="C:\test\Test.txt
And .txt:
option batch abort
option confirm off
open ***.**.**.**
lcd C:\Transfer\ToABCTest\
get -delete /test_edi_in/*.txt
close
exit
You have to specify the FTP protocol in the script using the ftp:// scheme in the session URL:
open ftp://***.**.**.**
Related
I am trying to automatically execute a SQL script with a batch file. Here is what I have in my batch file
#echo off
dbisql -c "Server=servername ;DBN=databasename ;UID=UserID;PWD=password" SqlFile.sql
pause
It says that the server was not found
If the server is not on the same machine, you have to tell the client that. You can do that in one of two ways:
Add the hostname of the machine where the server is running to the connection string, like: Server=<servername>;...;host=<hostname>. If the server is not running on the default port (2638), you can add the port number too, using host=<hostname>:<port>. This is the preferred method.
Add the links=tcpip parameter to the connection string. This is an older method and won't work if the server is on a different subnet.
I am creating a batch file to open a RDP session.
The remote desktop uses a gateway, so there are 2 credentials to be entered.
One for the gateway and other for the remote desktop.
I have written the following code:-
cmdkey /generic:gateway/abc.com /user:user1 /pass:password1
cmdkey /generic:TREMSRV/10.2.13.4 /user:user2 /pass:password2
start mstsc /v:10.2.13.4
But on running this code the pop to enter first set of credentials appears. I want to hardcode the credentials in the batch file itself
Can anyone suggest how shall i accomplish this ?
So I'm trying to transfer files to a remote computer on an SSH system. 'I've used the sftp command, used lls to confirm the presence of the file in the local computer, and then implemented the put filename command. However, I receive the same result each time:
stat filename: No such file or directory
I just don't know what's going wrong! Any help or troubleshooting tips would be appreciated.
If you're currently using Windows you can download winscp and use that to transfer files. It has a nice graphic interface that is easy to interact with
Well, supposing that you are on a Linux/Unix environment, you could use scp. Typically, the syntax for an scp command would be like this:
$ scp foobar.txt your_username#remotehost.net:/some/remote/directory
The above command copies the file foobar.txt which resides in the local computer, to a specific directory in the remote machine, using a username (you will be asked for a password later).
The sftp command line client uses the ssh transport and will tunnel your connections using your key. So if you have ssh access, you should also have sftp access. This is a secure option for people who are more comfortable with ftp. Most GUI ftp clients should also support sftp.
I was facing also in this issue when trying to upload files from the local to the remote server. I did commands well and clean but the mistake I was making was that: I've logged into the remote server with ssh and then login with sftp. In that way, sftp will consider that your remote server is the local (as I logged in first to this via ssh) when using the command below:
put /c/path/to/file.txt
So, the thing to do is to login directly to the server via sftp and putting your local files in there.
I am coding a program in C# to communicate with a remote PC in an Wifi AdHoc network. I execute a BATCH file in the remote that will send to the local a CHECK.txt file. I use PsExec.
Everything works fine in my C# program when I execute this batch file remotely with PsExec from the local PC to copy the CHECK.txt file in any of the remote's directories. The problem comes when I modify this BATCH to copy the text file to the LOCAL:
copy C:\Windows\CHECK.txt \\192.168.1.10\C$\Windows
It seems that the process PsExec, used to execute the BATCH in remote, blocks the communication of the network when the BATCH tries to send back to the local the text file. Ports 445 and 139 problem? Any idea of what is blocking the file to be sent back?
Everything is set for a transparent dialog between remote and local (no firewall, etc).
Thanks in advance...
I just noticed the -s parameter on your PSEXEC command. The -s means Run the remote process in the System account.. Removing it should allow your batch script to write back to local computer.
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/