YFNCG Posted June 9, 2006 Share Posted June 9, 2006 I just stumbled across this gem of a program and WOW is all I can say. I am a system administrator and the possibilities this opens up for automating repetitve tasks is awesomw. I am trying to write several scripts at the moment that will check for the existence of a particular "key file" and then perfom some file manipulation if the file is found. If the file is not found, for instance the first time the script is run, I need to be able to create an empty text file with a certain name in a particular place on the local hard drive. I have been unable to figure out how to create such a file from within a script. Any help will be appreciated. Thanks. JW Link to comment Share on other sites More sharing options...
Don N Posted June 9, 2006 Share Posted June 9, 2006 Look at _FileCreate in the helpfile/documentation. That should be what your are looking for. Also, look at FileFindFirstFile and FileFindNextFile to help you look for the files. _____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper Link to comment Share on other sites More sharing options...
YFNCG Posted June 9, 2006 Author Share Posted June 9, 2006 OK I took a look at the _FileCreate and I think I understand how it works. I have completed my script but when I try to run it nothing happens. I am planning to compile this and send it out to my users as an aid in troubleshooting network connectivity. Here is the script code: $TARGET = INPUTBOX("PING TARGET ENTRY", "Please enter the Hostname or URL you need to PING:", "", " M",) ; If NOT FileExists ( @WindowsDir\"ip.txt" ) then #include _FileCreate(@WindowsDir\"ip.txt") ; Make a throwaway file to avoid error on first run Endif SplashTextOn("Information on Ping Request", "Please be patient ! , The Ping of %TARGET% is running. Results will display shortly.") Sleep, 2000 FileDelete (@WindowsDir\ip.txt) Sleep, 2000 Ping -n=5 %TARGET% >> @WindowsDir\ip.txt ,,hide Sleep, 10000 SplashOff Run, notepad @WindowsDir\ip.txt Sleep, 2000 WinSetState(ip.txt - Notepad, "",@SW_MAXIMIZE) Exit ANy idease as to why this will not work? Thanks again. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 9, 2006 Moderators Share Posted June 9, 2006 OK I took a look at the _FileCreate and I think I understand how it works. I have completed my script but when I try to run it nothing happens. I am planning to compile this and send it out to my users as an aid in troubleshooting network connectivity. Here is the script code:$TARGET = INPUTBOX("PING TARGET ENTRY", "Please enter the Hostname or URL you need to PING:", "", " M",);If NOT FileExists ( @WindowsDir\"ip.txt" ) then #include _FileCreate(@WindowsDir\"ip.txt") ; Make a throwaway file to avoid error on first runEndifSplashTextOn("Information on Ping Request", "Please be patient ! , The Ping of %TARGET% is running. Results will display shortly.")Sleep, 2000FileDelete (@WindowsDir\ip.txt)Sleep, 2000Ping -n=5 %TARGET% >> @WindowsDir\ip.txt ,,hideSleep, 10000SplashOffRun, notepad @WindowsDir\ip.txtSleep, 2000WinSetState(ip.txt - Notepad, "",@SW_MAXIMIZE)ExitANy idease as to why this will not work?Thanks again.Are you using AutoItv2 and Not AutoItv3?Either way, you delete the file you want to ping before you ping it. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
YFNCG Posted June 9, 2006 Author Share Posted June 9, 2006 Are you using AutoItv2 and Not AutoItv3?Either way, you delete the file you want to ping before you ping it.Using v3. I thought that the IP.TXT file was simply the file where the output of the ping process would be re-directed to. At least that is the intention. The IP address or hostname to ping should come from the InputBox variable $TARGET. Link to comment Share on other sites More sharing options...
BigDod Posted June 9, 2006 Share Posted June 9, 2006 Using v3. I thought that the IP.TXT file was simply the file where the output of the ping process would be re-directed to. At least that is the intention. The IP address or hostname to ping should come from the InputBox variable $TARGET.If you are using V3 I suggest you look at the help file for the correct syntax for Run & Sleep. You will also need to change your Ping command. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 9, 2006 Moderators Share Posted June 9, 2006 If your using V3, then your syntax is completely wrong on your function calls. Sleep, 2000 = Sleep(2000) / Run, notepad @WindowsDir\ip.txt = Run('notepade.exe ' & '"' & @WindowsDir & '\ip.txt' & '"') etc... the Ping is wrong too, where did you get your syntaxing from out of curiousity? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
YFNCG Posted June 9, 2006 Author Share Posted June 9, 2006 If your using V3, then your syntax is completely wrong on your function calls.Sleep, 2000 = Sleep(2000) / Run, notepad @WindowsDir\ip.txt = Run('notepade.exe ' & '"' & @WindowsDir & '\ip.txt' & '"') etc... the Ping is wrong too, where did you get your syntaxing from out of curiousity?Sorry about that. Some of the syntaxt came from a v2 sample script. I have made some modifications but when I run the script nothing happens. No inputbox no error message. Here is the edited text:$TARGET = INPUTBOX("PING TARGET ENTRY", "Please enter the Hostname or URL you need to PING:", "", " M",);If NOT FileExists ( @WindowsDir\"ip.txt" ) then #include _FileCreate(@WindowsDir\"ip.txt") ; Make a throwaway file to avoid error on first runEndifSplashTextOn("Information on Ping Request", "Please be patient ! , The Ping of %TARGET% is running. Results will display shortly.")Sleep (2000)_RunDOS (Ping -n=5 %TARGET%) > @WindowsDir\"ip.txt"Sleep (10000)SplashOffRun (notepad.exe, @WindowsDir\"ip.txt")WinSetState(ip.txt - Notepad, "",@SW_MAXIMIZE)Exit Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 9, 2006 Moderators Share Posted June 9, 2006 Your not using SciTe are you?Download SciTe 6/02/2006 release here, and run your scripts from that, you'll see your errors. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
YFNCG Posted June 9, 2006 Author Share Posted June 9, 2006 (edited) Your not using SciTe are you?Download SciTe 6/02/2006 release here, and run your scripts from that, you'll see your errors.No I was using ConText which has AutoIt highlighters as well. I am downloading SciTe as I type.This is what I see in SciTe but I am not sure what is wrong:$TARGET = INPUTBOX("PING TARGET ENTRY", "Please enter the Hostname or URL you need to PING:", "", " M",);If NOT FileExists ( @WindowsDir\"ip.txt" ) then #include _FileCreate(@WindowsDir\"ip.txt") ; Make a throwaway file to avoid error on first runEndifSplashTextOn("Information on Ping Request", "Please be patient ! , The Ping of %TARGET% is running. Results will display shortly.")Sleep (2000)_RunDOS (Ping -n=5 %TARGET%) > @WindowsDir\"ip.txt"Sleep (10000)SplashOffRun (notepad.exe, @WindowsDir\"ip.txt")WinSetState(ip.txt - Notepad, "",@SW_MAXIMIZE)Exit Edited June 9, 2006 by YFNCG Link to comment Share on other sites More sharing options...
BigDod Posted June 9, 2006 Share Posted June 9, 2006 I am feeling generous, study and learn #include <File.au3> #include <Process.au3> $TARGET = INPUTBOX("PING TARGET ENTRY", "Please enter the Hostname or URL you need to PING:") ; If NOT FileExists ( @WindowsDir & "\ip.txt" ) then _FileCreate(@WindowsDir & "\ip.txt"); Make a throwaway file to avoid error on first run Endif SplashTextOn("Information on Ping Request", "Please be patient ! , The Ping of " & $TARGET & " is running. Results will display shortly.") Sleep (2000) _RunDOS ("Ping -n 5 " & $TARGET & ">>" & @WindowsDir & "\ip.txt") Sleep (10000) SplashOff () Run ("notepad.exe " & @WindowsDir & "\ip.txt") WinSetState("ip.txt - Notepad", "",@SW_MAXIMIZE) Exit Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
YFNCG Posted June 9, 2006 Author Share Posted June 9, 2006 I am feeling generous, study and learn #include <File.au3> #include <Process.au3> $TARGET = INPUTBOX("PING TARGET ENTRY", "Please enter the Hostname or URL you need to PING:") ; If NOT FileExists ( @WindowsDir & "\ip.txt" ) then _FileCreate(@WindowsDir & "\ip.txt"); Make a throwaway file to avoid error on first run Endif SplashTextOn("Information on Ping Request", "Please be patient ! , The Ping of " & $TARGET & " is running. Results will display shortly.") Sleep (2000) _RunDOS ("Ping -n 5 " & $TARGET & ">>" & @WindowsDir & "\ip.txt") Sleep (10000) SplashOff () Run ("notepad.exe " & @WindowsDir & "\ip.txt") WinSetState("ip.txt - Notepad", "",@SW_MAXIMIZE) Exit Thanks a million BD. I have a lot to learn about this powerful program but I usually pick thing up pretty quick. This forum is awesome. I have never had such a quick response from any other software forum before. It is really appreciated. Link to comment Share on other sites More sharing options...
BigDod Posted June 9, 2006 Share Posted June 9, 2006 Thanks a million BD. I have a lot to learn about this powerful program but I usually pick thing up pretty quick. This forum is awesome. I have never had such a quick response from any other software forum before. It is really appreciated.This is a great place to start learning. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
CyberSlug Posted June 9, 2006 Share Posted June 9, 2006 ;another way Run(@ComSpec & " /c copy nul > myEmptyFile.txt", "", @SW_HIDE) Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
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