MrChris Posted August 8, 2006 Posted August 8, 2006 I have a 2 inputbox prompts, One that asks for a Server Name and the other that ask for a Port Number. It writes the answers to both in a single file. I am needing to append the answers to 2 different lines on the file it opens, But its only appending the answer to 1 of the lines the other is putting my answer to a new line. expandcollapse popup#Region --- CodeWizard generated code Start --- ;InputBox features: Title=Yes, Prompt=Yes, Default Text=No, Mandatory, Height=140 Global $Port Global $ServerNameAnswer $Port = "Port" If Not IsDeclared("ServerNameAnswer") Then Dim $ServerNameAnswer $ServerNameAnswer = InputBox("Server IP Address","Provide the IP or Host Name of the OpenVPN Server : ",""," M","-1","140","-1","-1") Select Case @Error = 0 ;OK - The string returned is valid Case @Error = 1 ;The Cancel button was pushed Case @Error = 3 ;The InputBox failed to open EndSelect $CLIENT_CONFIG = FileOpen("C:\PROGRAM FILES\OPENVPN\CONFIG\CLIENT.OVPN",1) FileWriteLine($CLIENT_CONFIG, $ServerNameAnswer) FileWriteLine($CLIENT_CONFIG, $Port) FileClose($CLIENT_CONFIG) If Not IsDeclared("PortNumberAnswer") Then Dim $PortNumberAnswer $PortNumberAnswer = InputBox("Server Port Number","Provide the Port Number of the OpenVPN Server : ",""," M","-1","140","-1","-1") Select Case @Error = 0 ;OK - The string returned is valid Case @Error = 1 ;The Cancel button was pushed Case @Error = 3 ;The InputBox failed to open EndSelect $CLIENT_CONFIG = FileOpen("C:\PROGRAM FILES\OPENVPN\CONFIG\CLIENT.OVPN",1) FileWriteLine($CLIENT_CONFIG, $PortNumberAnswer) FileClose($CLIENT_CONFIG) #EndRegion --- CodeWizard generated code End --- The Client.ovpn Config file already has a REMOTE and PORT line I just want to append the answer to both of those lines. What am I missing? Thanks, MrChris
evilertoaster Posted August 8, 2006 Posted August 8, 2006 I'm having trouble understanding that Can you maybe post- 1. What the file says at first 2. What it says after 3. What it is suposed to say after That should help me help you!
/dev/null Posted August 8, 2006 Posted August 8, 2006 I have a 2 inputbox prompts, One that asks for a Server Name and the other that ask for a Port Number. It writes the answers to both in a single file. I am needing to append the answers to 2 different lines on the file it opens, But its only appending the answer to 1 of the lines the other is putting my answer to a new line. The Client.ovpn Config file already has a REMOTE and PORT line I just want to append the answer to both of those lines. What am I missing? Thanks, MrChris FileWriteLine() adds CRLF at the end of a line. Build the string you want to add to the file and then use ONE FileWriteLine() call. $output = $ServerNameAnswer & @CRLF & $port & $PortNumberAnswer & @CRLF FileWriteLine($CLIENT_CONFIG, $output) Cheers Kurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
MrChris Posted August 8, 2006 Author Posted August 8, 2006 Sorry, Maybe this will help. Before: proto tcp-client tun-mtu 1500 ifconfig 10.10.10.2 255.255.255.0 dev tap secret key.txt comp-lzo3 remote Port oÝ÷ Ù«¢+ÙÁɽѼÑÀµ±¥¹Ð)ÑÕ¸µµÑÔÄÔÀÀ)¥½¹¥ÄÀ¸ÄÀ¸ÄÀ¸ÈÈÔÔ¸ÈÔÔ¸ÈÔÔ¸À)ØÑÀ)ÍÉÐä¹ÑáÐ)½µÀµ±é¼Ì)ɵ½ÑÄäÈ¸ÄØà¸Ä¸ÄÀÀ)A½ÉÐÄÈÌÐ(
evilertoaster Posted August 8, 2006 Posted August 8, 2006 O yea then kinda what /dev/null said...you can make the file yourself too- FileWriteLine($CLIENT_CONFIG,"proto tcp-client") FileWriteLine($CLIENT_CONFIG,"tun-mtu 1500") FileWriteLine($CLIENT_CONFIG,"ifconfig 10.10.10.2 255.255.255.0") FileWriteLine($CLIENT_CONFIG,"dev tap") FileWriteLine($CLIENT_CONFIG,"secret key.txt") FileWriteLine($CLIENT_CONFIG,"comp-lzo3") FileWriteLine($CLIENT_CONFIG,"remote "&$ServerNameAnswer) FileWriteLine($CLIENT_CONFIG,"Port "&$PortNumberAnswer) or so...
MrChris Posted August 8, 2006 Author Posted August 8, 2006 Thanks to both of you. @evilertoaster, I didnt even think about that. That worked even easier than what I was trying to do. Thanks again, MrChris
JawwadRauf Posted August 24, 2011 Posted August 24, 2011 $DATE = @MDAY & "/" & @MON & "/" & @YEAR $file = FileOpen("D:\Report.txt", 1) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWriteLine($file, "Date: ", $DATE ) FileWriteLine($file, "" & @CRLF) FileClose($file) _________________________________________________________________ FileWriteLine($file, "Date: ", $DATE) ^ ERROR >Exit code: 1 Time: 0.207 ________________________________________________________________ please help me i cant put the date function output(spose to be like this "Date: 24/08/2011" in to the txt file every time do that its give me the error help me out
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