Page 1 of 1 1
Topic Options
#212667 - 2017-09-07 09:03 PM how to use SFTP instead of FTP transfers
Patrick99 Offline
Fresh Scripter

Registered: 2016-02-19
Posts: 14
Loc: Belgium
Dear friends
currently i'm using FTP to transfer some cleartxt data from a client to a server because its not business data, but now I would include confidenial data so we have to swing over to SFTP server. how can I convert my script?
 Code:
 $local="c:\windows\test"
 $Patch="c:\windows\test"
 $dirs="cd"
 $site2="62.xx.xx.xx"
 $site2_user="test\Bello"
 $site2_pw="Belloxxxxx"
 
:ftp_files
 Del "c:\windows\test\ftp.cmd"
 If (Open(1,"c:\windows\test\ftp.cmd",5) = 0)

  $nul=WriteLine(1,"open $site2"+Chr(13)+Chr(10))
  $nul=WriteLine(1,"$site2_user"+Chr(13)+Chr(10))
  $nul=WriteLine(1,"$site2_pw"+Chr(13)+Chr(10))
  $nul=WriteLine(1," binary"+Chr(13)+Chr(10))
  $nul=WriteLine(1," status"+Chr(13)+Chr(10))
  $nul=WriteLine(1," mkdir"+ " Easy_reports\" + $NAME + Chr(13)+Chr(10))
  $nul=WriteLine(1," cd"+Chr(13)+Chr(10))
   $nul=WriteLine(1," FEasy_reports\" + $NAME +Chr(13)+Chr(10))
   $nul=WriteLine(1," lcd "+ $Patch + Chr(13)+Chr(10))
   $nul=WriteLine(1," mput $local\*.*"+Chr(13)+Chr(10))
   $nul=WriteLine(1," delete "+ "test.exe" + Chr(13)+Chr(10))
   $nul=WriteLine(1," delete "+ "ftp.cmd" + Chr(13)+Chr(10))
   $nul=WriteLine(1,"close"+Chr(13)+Chr(10))
   $nul=WriteLine(1,"quit"+Chr(13)+Chr(10))
   If Close(1)
   EndIf
 EndIf
 Sleep 2
 Shell '%comspec% /c ftp -d -i -s:c:\windows\test\ftp.cmd '
 Sleep 15


Edited by Mart (2017-09-08 09:15 AM)
Edit Reason: Please use code tags when posting code.

Top
#212668 - 2017-09-08 09:17 AM Re: how to use SFTP instead of FTP transfers [Re: Patrick99]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
ftp.exe that is included in the OS does not support SFTP at the moment. That may change but that would be up to Microsoft.
swicthing to WinSCP should do the trick.

An example: https://stackoverflow.com/questions/21102193/replace-windows-command-ftp-se-ftpscript-txt-with-sftp
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#212669 - 2017-09-08 11:38 AM Re: how to use SFTP instead of FTP transfers [Re: Mart]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
Putty is another option. Also, just a short difference between sftp and scp which is more important when scripting. If you use sftp and open a session, even if none of the files get transferred, sftp will close without any errors. It is a batch session. If you use scp, each transaction will tell you the success or failure of the transfer. So, you can keep track of the results better.
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.051 seconds in which 0.021 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org