olmanRvr Posted November 19, 2016 Posted November 19, 2016 I have a compiled script :-timeStampSecs.exe which returns timestamp in seconds. I call it in FileWrite to write the time stamp in a text file.But it writes some other values instead of the timestamp. Please help. thanks olmar The script is below:- $kNum=run("timeStampSecs.exe","",1); also tried with flags 2,4,8,10 $hFile=FileOpen("timeStamp.txt",2) FileWrite($hFile,"the key is: "&$kNum) FileClose("$hFile") ;Code of thetimeStampSecs.exe:- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #include <Date.au3> Func secFromEpoch() Local $ts=_DateDiff( "s","1970/01/01 00:00:00",_NowCalc()) $ts=String($ts) ConsoleWrite("timeStamp is: "&$ts&@CRLF) Return $ts EndFunc secFromEpoch()
kylomas Posted November 19, 2016 Posted November 19, 2016 olmanRvr, Look at the help file for run. RUN returns the PID if successful. If you want to write the time stamp to a file you will have to do that in the script that calculates it. You can pass in a file name as a command line parameter if you wish. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
olmanRvr Posted November 19, 2016 Author Posted November 19, 2016 Hi, Thanks for the quick reply.Let me try your suggestion .Will let you know olmar
Moderators Melba23 Posted November 19, 2016 Moderators Posted November 19, 2016 olmanRvr, Or you can read the return stream of the process like this: #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> Local $iPID = Run("timeStampSecs.exe", "", @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) Local $sOutput While 1 $sTemp = StdoutRead($iPID) $sTemp &= StderrRead($iPID) ; Exit the loop if the process closes or StdoutRead returns an error. If @error Then ExitLoop Else $sOutput &= $sTemp EndIf Sleep(10) WEnd MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput) M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Developers Jos Posted November 19, 2016 Developers Posted November 19, 2016 Or simply use RunWait()? Jos Melba23 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
snoopie Posted November 19, 2016 Posted November 19, 2016 FileClose("$hFile") should rather be FileClose($hFile) just a typo though. When calling command line executables I quite often have more succes using: Run(@ComSpec & " /c " & ...)
olmanRvr Posted November 19, 2016 Author Posted November 19, 2016 Instead of Run used RunWait as per Jos .Same issue--- writing PID numbers in place of the time stamp as wanted.Also removes quotes from fileclose like "$hFile"-->$hFile but doesn't help. Working on reading the return stream(as per Melba23's suggestion). see you.........
olmanRvr Posted November 19, 2016 Author Posted November 19, 2016 Read stream of run call to timeStampSecs.exe .But still getting blank output(in consoleWrite.See code below:-- #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> Func readStream() Local $iPID = Run("timeStampSecs.exe", "", @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) Local $sOutput While 1 $sTemp = StdoutRead($iPID) $sTemp &= StderrRead($iPID) ; Exit the loop if the process closes or StdoutRead returns an error. If @error Then ExitLoop Else $sOutput &= $sTemp EndIf Sleep(10) WEnd MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput) ConsoleWrite("ts is: "&$sOutput&@CRLF) Return $sOutput EndFunc readStream()
Developers Jos Posted November 19, 2016 Developers Posted November 19, 2016 18 minutes ago, olmanRvr said: Instead of Run used RunWait as per Jos .Same issue--- writing PID numbers Nah, RunWait() returns the Returncode of the shelled program. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Moderators Melba23 Posted November 19, 2016 Moderators Posted November 19, 2016 olmanRvr, The StdoutRead code worked for me with a compiled version of the script you posted in the OP, as did Jos' suggestion. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
kylomas Posted November 19, 2016 Posted November 19, 2016 olmanRvr, Works perfectly for me like this (M23 code modified)... #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> Local $iPID = Run(@scriptdir & "\timeStampSecs.exe", "", @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) Local $sOutput While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop Sleep(10) WEnd MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput) kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
olmanRvr Posted November 19, 2016 Author Posted November 19, 2016 (edited) Hi kylomas, Tried the code you have shown.Yes, it is showing the timestamp in a GUI window.Problem arises when I add the following line:- ConsoleWrite("value is: "&$sOutput&@CRLF) ConsoleWrite fails to write the value.Same issue occurs when writing the value of $sOutput to a text file.Weird thing is if I replace the timeStampSecs.exe with genKeyNum.exe it works fine !! Any idea, anyone please? example below: ;Only difference to the previous function is that another exe file is invoked Func runExegenKeyNum();the exe fetches the physical drive number Local $iPID = Run(@scriptdir & "\genKeyNum.exe", "", @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) Local $sOutput While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop Sleep(10) WEnd MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput) ConsoleWrite("value is; "&$sOutput&@CRLF) Return $sOutput EndFunc runExegenKeyNum() ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ;code for genKeyNum.exe Func gtSrNo() $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" Global $Output="" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) For $oItm In $colItems $Output = $Output & $oItm.SerialNumber & @CRLF Next ConsoleWrite($Output&@CRLF) Return $Output;$Output is the serial; number EndFunc Edited November 19, 2016 by olmanRvr typho
jchd Posted November 19, 2016 Posted November 19, 2016 Sideways offer: why not including the various function in the main script instead of invoking them compiled as as many executables? This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
olmanRvr Posted November 20, 2016 Author Posted November 20, 2016 Hi, I would hard code these values(Hd srnum×tamp) into the code for each user, basically to bind it to a single machine for a predefined period.Hence in the last moment, after user clicks download button,these values are fetched and incorporated into the script & then compiled .Which will, then be downloaded. But thanks for your reply olmar
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