Dudka Posted June 18, 2008 Posted June 18, 2008 Could anybody tell me why StringRegExp("[11]|-rw-r--r-- 1 ixb ixb 53295 Jun 18 18:39 1706.BAL","-r.?-r.?-r.?-.*ixb\s*(\d+).*1706.BAL",3) does not return any result?Javascript based regular expressions work fine with this exampleWhats with autoit?
PsaltyDS Posted June 18, 2008 Posted June 18, 2008 Could anybody tell me why StringRegExp("[11]|-rw-r--r-- 1 ixb ixb 53295 Jun 18 18:39 1706.BAL","-r.?-r.?-r.?-.*ixb\s*(\d+).*1706.BAL",3) does not return any result? Javascript based regular expressions work fine with this example Whats with autoit? Works for me. You do know the matches are in an array... right? #include <Array.au3> $avRET = StringRegExp("[11]|-rw-r--r-- 1 ixb ixb 53295 Jun 18 18:39 1706.BAL","-r.?-r.?-r.?-.*ixb\s*(\d+).*1706.BAL",3) $iErrSav = @error $iExtSav = @extended If IsArray($avRET) Then _ArrayDisplay($avRET, "Results") Else MsgBox(16, "Error", "@error = " & $iErrSav & " @extended = " & $iExtSav) EndIf Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Dudka Posted June 19, 2008 Author Posted June 19, 2008 (edited) Works for me. You do know the matches are in an array... right? #include <Array.au3> $avRET = StringRegExp("[11]|-rw-r--r-- 1 ixb ixb 53295 Jun 18 18:39 1706.BAL","-r.?-r.?-r.?-.*ixb\s*(\d+).*1706.BAL",3) $iErrSav = @error $iExtSav = @extended If IsArray($avRET) Then _ArrayDisplay($avRET, "Results") Else MsgBox(16, "Error", "@error = " & $iErrSav & " @extended = " & $iExtSav) EndIf Hm. Your example works fine. Yes, i know that array returns as the result. Cant's figure out whats wrong here #Include <File.au3> #include <Array.au3> Func _FtpPutFile($server,$remotedir,$file_name,$user='anonymous',$password='mail@tome.com',$port='21') $commandfilename=_TempFile() $resultsname=_TempFile() $handle=FileOpen($commandfilename,2) FileWriteLine($handle,"open "&$server&" "&$port) FileWriteLine($handle,$user) FileWriteLine($handle,$password) FileWriteLine($handle,"cd ."&$remotedir) FileWriteLine($handle,"binary") FileWriteLine($handle,"put "&$file_name) FileWriteLine($handle,"dir") FileWriteLine($handle,"bye") FileClose($handle) RunWait(@ComSpec & " /c ftp -s:" & $commandfilename & " >" & $resultsname, "", @SW_HIDE) FileDelete($commandfilename) $data=FileRead($resultsname) FileDelete($resultsname) $f_s=StringRegExp($data,"-r.?-r.?-r.?-.*"&$user&"\s*(\d+).*"&$file_name,3) ;~ _ArrayDisplay($f_s) Return $f_s[0]=FileGetSize($file_name) EndFunc Edited June 19, 2008 by Dudka
PsaltyDS Posted June 19, 2008 Posted June 19, 2008 (edited) Hm. Your example works fine. Yes, i know that array returns as the result. Cant's figure out whats wrong here #Include <File.au3> #include <Array.au3> Func _FtpPutFile($server,$remotedir,$file_name,$user='anonymous',$password='mail@tome.com',$port='21') $commandfilename=_TempFile() $resultsname=_TempFile() $handle=FileOpen($commandfilename,2) FileWriteLine($handle,"open "&$server&" "&$port) FileWriteLine($handle,$user) FileWriteLine($handle,$password) FileWriteLine($handle,"cd ."&$remotedir) FileWriteLine($handle,"binary") FileWriteLine($handle,"put "&$file_name) FileWriteLine($handle,"dir") FileWriteLine($handle,"bye") FileClose($handle) RunWait(@ComSpec & " /c ftp -s:" & $commandfilename & " >" & $resultsname, "", @SW_HIDE) FileDelete($commandfilename) $data=FileRead($resultsname) FileDelete($resultsname) $f_s=StringRegExp($data,"-r.?-r.?-r.?-.*"&$user&"\s*(\d+).*"&$file_name,3) ;~ _ArrayDisplay($f_s) Return $f_s[0]=FileGetSize($file_name) EndFunc Since nothing calls _FtpPutFile(), and I won't connect to your FTP server anyway, that isn't very helpful. How about just posting and example string for $data that we can see failing in this: $data = "Provide an example string that doesn't work for you..." & @CRLF & _ "It can be a multiline string that represents the FTP.exe STDOUT that you typically capture" & @CRLF & _ "with your script. Just comment out the deletion of $resultsname and post its contents." $user = "FailingUserNameExample" $file_name = "FailingFileNameExample" $f_s = StringRegExp($data, "-r.?-r.?-r.?-.*" & $user & "\s*(\d+).*" & $file_name, 3) $iErrSav = @error $iExtSav = @extended If IsArray($f_s) Then MsgBox(64, "Result", "$f_s[0] = " & $f_s[0]) Else MsgBox(16, "Error", "$f_s is not an array, @error = " & $iErrSav & ", @extended = " & $iExtSav) EndIf We may find your issue has nothing at all to do with RegExp. Edited June 19, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Dudka Posted June 19, 2008 Author Posted June 19, 2008 (edited) Since nothing calls _FtpPutFile(), and I won't connect to your FTP server anyway, that isn't very helpful. How about just posting and example string for $data that we can see failing in this: $data = "Provide an example string that doesn't work for you..." & @CRLF & _ "It can be a multiline string that represents the FTP.exe STDOUT that you typically capture" & @CRLF & _ "with your script. Just comment out the deletion of $resultsname and post its contents." $user = "FailingUserNameExample" $file_name = "FailingFileNameExample" $f_s = StringRegExp($data, "-r.?-r.?-r.?-.*" & $user & "\s*(\d+).*" & $file_name, 3) $iErrSav = @error $iExtSav = @extended If IsArray($f_s) Then MsgBox(64, "Result", "$f_s[0] = " & $f_s[0]) Else MsgBox(16, "Error", "$f_s is not an array, @error = " & $iErrSav & ", @extended = " & $iExtSav) EndIf We may find your issue has nothing at all to do with RegExp. thx a lot 4 help & patience i have solved my problem. The error was in pattern. as a $file_name i use full path like 'c:\boot.ini' so no results was returned. so working functuion is #Include <File.au3> #include <Array.au3> Func _FtpPutFile($server,$remotedir,$file_name,$user='anonymous',$password='mail@tome.com',$port='21') Dim $szDrive, $szDir, $szFName, $szExt $commandfilename=_TempFile() $resultsname=_TempFile() $handle=FileOpen($commandfilename,2) FileWriteLine($handle,"open "&$server&" "&$port) FileWriteLine($handle,$user) FileWriteLine($handle,$password) FileWriteLine($handle,"cd ."&$remotedir) FileWriteLine($handle,"binary") FileWriteLine($handle,"put "&$file_name) FileWriteLine($handle,"dir") FileWriteLine($handle,"bye") FileClose($handle) RunWait(@ComSpec & " /c ftp -s:" & $commandfilename & " >" & $resultsname, "", @SW_HIDE) FileDelete($commandfilename) $data=FileRead($resultsname) FileDelete($resultsname) $sp=_PathSplit($file_name,$szDrive, $szDir, $szFName, $szExt) $f_s=StringRegExp($data,"-r.?-r.?-r.?-.*"&$user&"\s*(\d+).*"&$sp[3]&$sp[4],3) ;~ _ArrayDisplay($f_s) Return $f_s[0]=FileGetSize($file_name) EndFunc Edited June 19, 2008 by Dudka
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now