Jump to content

[solved] RUN command cannot find SFTP.EXE

Go to solution Solved by Chimp,

Recommended Posts

I would like to control SFTP.EXE via the RUN command.
If I solve the problem with SEND commands, I can get SFTP.EXE.
But when I work with the RUN command. SFTP.EXE is not found.
What am I doing wrong?
Here is a test script:

$host = "u76297179@home515426626.1and1-data.host"

;~ First, here's the proof that SFTP.EXE works.

Send('#xi')            ; call CMD window
Send('sftp.exe ' & $host & '{enter}')        ; call SFTP
Send('nopass{enter}')                ; enter an invalid Password
For $i = 1 To 4
    Send('{enter}')                ; enter an null Password

;~ Now try with the RUN command
;~ Why is SFTP.EXE not found?

$rc = Run(@ComSpec & " /k sftp.exe " & $host)
ConsoleWrite("Error: " & @error & " Extended: " & @extended & " Line: " & @ScriptLineNumber & " RC: " & $rc & @LF)

 Output of SEND:

Microsoft Windows [Version 10.0.19044.1320]
(c) Microsoft Corporation. Alle Rechte vorbehalten.

C:\Users\xxx>sftp.exe u76297179@home515426626.1and1-data.host
u76297179@home515426626.1and1-data.host's password:
Permission denied, please try again.
u76297179@home515426626.1and1-data.host's password:
Permission denied, please try again.
u76297179@home515426626.1and1-data.host's password:
u76297179@home515426626.1and1-data.host: Permission denied (publickey,password).
Connection closed


Output of RUN:

Der Befehl "sftp.exe" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.


Google translation:

The command "sftp.exe" is either misspelled or
could not be found.

C: \ Users \ xxx \ Documents \ Data \ Autoit>


Why is SFTP.EXE not found?

Edited by Exit

App: Au3toCmd              UDF: _SingleScript()                             

Link to post
Share on other sites
  • Solution

try adding this lines at the beginning of your script:

#include <WinAPIFiles.au3>

;Turn off redirection for a 32-bit script on 64-bit system.
If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False)


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to post
Share on other sites

@Chimpyou are the champ :thumbsup:

u76297179-sftp@home515426626.1and1-data.host's password:
Connected to home515426626.1and1-data.host.
sftp> ?
Available commands:
bye                                Quit sftp
cd path                            Change remote directory to 'path'
chgrp [-h] grp path                Change group of file 'path' to 'grp'
chmod [-h] mode path               Change permissions of file 'path' to 'mode'
chown [-h] own path                Change owner of file 'path' to 'own'
df [-hi] [path]                    Display statistics for current directory or
                                   filesystem containing 'path'
exit                               Quit sftp
get [-afpR] remote [local]         Download file
help                               Display this help text
lcd path                           Change local directory to 'path'
lls [ls-options [path]]            Display local directory listing
lmkdir path                        Create local directory
ln [-s] oldpath newpath            Link remote file (-s for symlink)
lpwd                               Print local working directory
ls [-1afhlnrSt] [path]             Display remote directory listing
lumask umask                       Set local umask to 'umask'
mkdir path                         Create remote directory
progress                           Toggle display of progress meter
put [-afpR] local [remote]         Upload file
pwd                                Display remote working directory
quit                               Quit sftp
reget [-fpR] remote [local]        Resume download file
rename oldpath newpath             Rename remote file
reput [-fpR] local [remote]        Resume upload file
rm path                            Delete remote file
rmdir path                         Remove remote directory
symlink oldpath newpath            Symlink remote file
version                            Show SFTP version
!command                           Execute 'command' in local shell
!                                  Escape to local shell
?                                  Synonym for help


App: Au3toCmd              UDF: _SingleScript()                             

Link to post
Share on other sites
  • Exit changed the title to [solved] RUN command cannot find SFTP.EXE

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Gauss
      I have started using this UDF SFTPEx.au3 to download a bunch of files from a remote server to local. 
      First, Great job with the UDF and this really works! awesome work Lupo73...
      Second, there is no timestamps on the listed files when I use the function _SFTP_ListToArrayEx. Screenshots attached
      Third, Is the _SFTP_ProgressDownload function still Work in Progress?
      I am using the version 1.0 beta 9
            using _ArrayDisplay function
          using Filezilla
      Can the developers please help me with these questions?
    • By mLipok
      Hi all.
      Today I would like to introduce the beginning of the UDF.
      How to get started:
      Original readme_automation.txt:

      now I have only one function (standard FTP on standard port) to show the future possibilities:
      Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Const Enum _ $__eWSCP_SO_Protocol_Sftp, _ $__eWSCP_SO_Protocol_Scp, _ $__eWSCP_SO_Protocol_Ftp Const Enum _ $__eWSCP_TO_TransferMode_Binary, _ $__eWSCP_TO_TransferMode_Ascii, _ $__eWSCP_TO_TransferMode_Automatic Example_PutFile('YOUR FTP HOST NAME', 'YOUR USER NAME', 'YOUR PASSWORD') Func Example_PutFile($sHostName, $sUserName, $sPassword) Local $sFileFullPath = StringReplace(@ScriptFullPath, '\', '\\') Local $sFilesToPut = StringReplace(@ScriptDir & '\*.au3', '\', '\\') ; based on: ; http://winscp.net/eng/docs/library_com_wsh#vbscript Local $oSessionOptions = ObjCreate("WinSCP.SessionOptions"); With $oSessionOptions .Protocol = $__eWSCP_SO_Protocol_Ftp .HostName = $sHostName; .UserName = $sUserName; .Password = $sPassword; ; below not jet tested ; .SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" EndWith Local $oSession = ObjCreate("WinSCP.Session"); With $oSession ; Connect: Open sesion with defined options .Open($oSessionOptions); ; Set TransferOptions Local $oTransferOptions = ObjCreate("WinSCP.TransferOptions") $oTransferOptions.TransferMode = $__eWSCP_TO_TransferMode_Binary ; Upload files: put @ScriptFullPath to the ROOT directory Local $oTransferResult = .PutFiles($sFilesToPut, '/'); ; Throw on any error $oTransferResult.Check ; Print results For $oTransfer In $oTransferResult.Transfers ConsoleWrite("Upload of " & $oTransfer.FileName & " succeeded" & @CRLF) Next ;' Disconnect, clean up .Dispose() EndWith ; CleanUp $oSession = '' $oSessionOptions = '' EndFunc ;==>Example_PutFile Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc EDIT: 2014-06-20 04:47 - script changed
  • Create New...