Sign in to follow this  
Followers 0
Roman9

FileWriteLine not working in my code

5 posts in this topic

#1 ·  Posted (edited)

Hey everyone.

I'm writting a proxy checker in autoit and it works flawlessly, except for FileWriteLine (to output working proxies to a text file)

Here's a snippet of the code

$socket = TCPConnect($ip, $port)
         Sleep(500)
         $fault2 = _WSAGetLastError()
         if @extended Then
             msgbox (262144,"Fault","WSAGetLastError failed")
             $fault2 = 'unknown'
         EndIf
         If $socket = -1 Then
             Switch @error
                 Case 1
                     $fault = "Incorrect IP"
                 Case 2
                     $fault = "Incorrect port"
                 Case Else
                     $fault = "Valid IP and Port"
             EndSwitch
             MsgBox(262144, "Failed to connect","Error = " & $fault2 & @CRLF & $fault)
         Else
             FileWriteLine($outputFile, $currentLine & @CRLF)
         EndIf

Is socket ever != -1

I don't get it. :/

Edited by Roman9

Share this post


Link to post
Share on other sites



put a MsgBox in the else statement and see if it gets executed

Share this post


Link to post
Share on other sites

The MsgBox works :)

Share this post


Link to post
Share on other sites

The MsgBox works :)

check if FileWriteLine return 0, if yes, the error can be either a wrong handle or file name

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks for the help oMBRa!

After reviewing the help file further, I realized it was the mode I set with FileOpen :/

Changing

$outputFile = FileOpen("output.txt", 0)

to

$outputFile = FileOpen("output.txt", 1)

fixed everything

Edited by Roman9

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0