#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Comment=Upload a local file to defined path automatically #AutoIt3Wrapper_Res_Description=Upload a local file to defined path automatically #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #AutoIt3Wrapper_Res_Language=1033 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.12.1 Author: Christian Blank infofiles: lines: 1: title of active session window 2: command to login with winscp (/command "option confirm off") 3: title of winscp session (ohne Auswählen) 4: destination on server (rootdir) (/var/www/localhost/htdocs/) Dieses Programm läd eine Beliebige Datei auf den entsprechenden Server Hoch Der Pfad dazu wird in --TC--data/hps/ gesucht #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here Opt("TrayIconHide", 1);0=show, 1=hide tray icon global $tc = getvol("TC"); global $sd = getvol("SD"); if($cmdLine[0] > 0) then $file = $cmdLine[1]; if($cmdLine[0] > 1) Then ;;; MORE FILES AT ONCE for $x = 2 to $cmdline[0] runwait(@ScriptFullPath & " " & $cmdline[$x]) next endif Else msgbox(0,0,"First Parameter should be the local file to Upload, " & @crlf & _ "the second the window to show afterwards (optional)") exit endif if(fileexists($file) = false) Then msgbox(0,0,"Local file missing! - " & $file) Exit endif $rootdir = getrootdir($file) if($rootdir = "not found") Then msgbox(0,0,"rootdir not found!"); exit endif $y = 0; $morefiles = true while $morefiles=true ;loop for infofile_x ; Get infofile $infofile = $rootdir; $infofile = stringreplace($infofile,"\","_") $infofile = stringreplace($infofile,":","-") $infofile = $tc & "\data\hps\" & $infofile & $y & ".txt" if(FileExists($infofile) = false) Then if($y = 0) Then msgbox(0,0,"infofile not found!") Exit endif $morefiles = false Else $content = fileread($infofile) ;$content = stringreplace($content,@cr,"----------") $info = stringsplit($content,@cr); for $x = 1 to $info[0]-1 $info[$x] = stringreplace($info[$x],@crlf,"") $info[$x] = stringreplace($info[$x],@lf,"") $info[$x] = stringreplace($info[$x],@cr,"") next ;Create command for winscp $realrootdir = $rootdir $realrootdir = stringreplace($realrootdir,"--TC--",$tc) $realrootdir = stringreplace($realrootdir,"--SD--",$sd) $uploadname = StringReplace($file,$realrootdir,""); $uploadfullname = $info[4] & $uploadname $file = stringreplace($file,"/","\") $uploadfullname = stringreplace($uploadfullname,"\","/"); ;$winscpcommand = "put " & $file & " " & $uploadfullname $winscpcommand = "put """ & $file & """ """ & $uploadfullname & """";sdf WinActivate($info[1]) if(winactive($info[1])=False) Then WinActivate($info[3]) if(winactive($info[3])=false) Then $command = $info[2]; $command = stringreplace($command,"--TC--",$tc) ConsoleWrite($command); run($command) WinWaitActive($info[3],"",40) endif endif WinActivate($info[1]) if(winactive($info[1]) = false) Then WinActivate($info[3]) if(winactive($info[3]) = false) Then msgbox(0,0,"unable to run winscp") exit endif endif ; main action :-) AutoItSetOption("sendKeyDelay",0) AutoItSetOption("SendKeyDownDelay",0) send($winscpcommand & "{ENTER}") $y = $y +1 endif wend if($cmdLine[0] >= 2) then opt("WinTitleMatchMode",2) WinActivate($cmdLine[2]) endif func getrootdir($file) $content = fileread($tc & "\data\hps\indexfile.txt") $index = stringsplit($content,@crlf) $rootdir = "not found"; for $x = 1 to $index[0] $curr = $index[$x]; $curr = stringreplace($curr,"--TC--",$tc) $curr = stringreplace($curr,"--SD--",$sd) if(stringinstr($file,$curr)) Then $rootdir = $index[$x]; endif next return $rootdir; endfunc func getvol($type) if($type="SD") Then $file = "SDToken" EndIf if($type="TC") Then $file = "TCToken" endif $var = DriveGetDrive( "all" ) If NOT @error Then For $i = 1 to $var[0] $status = DriveStatus( $var[$i]); if($status = "READY") then ;if($var[$i] <> "a:" and $var[$i] <> "b:") then if(fileexists($var[$i] & "\" & $file)) Then return $var[$i] endif endif Next EndIf return false endfunc