Page 1 of 1 1
Topic Options
#13930 - 2001-11-05 05:20 PM Shell command to send date/time to a file
kdub Offline
Fresh Scripter

Registered: 2001-11-05
Posts: 22
Loc: Appleton, WI
I am brand new to kix32 and am trying to send date and time to a file. What am I
doing wrong? Script is as follows:

$LogFile = "c:\testdir\test.log"

SHELL 'cmd /c @date @time>"$LogFile"'

I've tried variations on this, with date and time concatenated, surrounded by quotes, but I get the error "'2001' is not recognized as an internal or external command, operable program or batch file"

Top
#13931 - 2001-11-05 05:27 PM Re: Shell command to send date/time to a file
Anonymous
Unregistered


Try this:

$logFile = "c:\testdir\test.log"
Shell "%comspec% /c echo @DATE @TIME > $logFile"

HTH, Martijn

Top
#13932 - 2001-11-05 05:28 PM Re: Shell command to send date/time to a file
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
to use things like redirect's "> < |" these are part of the command interputer.

For win9x/me this is command.com
for XP/W2k/nt this is cmd.exe

All MS operation systems have a environment variable called %comspec% that points to the correct file.

You will want to use the DOS ECHO command for this action.

shell '%comspec% /c echo @date/Time > file.txt'

[ 05 November 2001: Message edited by: Bryce ]

Top
#13933 - 2001-11-05 05:36 PM Re: Shell command to send date/time to a file
kdub Offline
Fresh Scripter

Registered: 2001-11-05
Posts: 22
Loc: Appleton, WI
Thank you both! Works great.
Top
#13934 - 2001-11-05 07:03 PM Re: Shell command to send date/time to a file
Anonymous
Unregistered


Why not just use the Open(), WriteLine() and Close() functions?
Top
#13935 - 2001-11-05 07:07 PM Re: Shell command to send date/time to a file
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
... or the RedirectOutput() function for that matter

J.

_________________________



Top
#13936 - 2001-11-05 08:23 PM Re: Shell command to send date/time to a file
Anonymous
Unregistered


What are advantages of working that way? Is it faster?

Martijn

Top
#13937 - 2001-11-05 08:44 PM Re: Shell command to send date/time to a file
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Using open() writeline() close() or redirectoutput() can lock a file open. This is not a problem if only 1 user at a time will be writting to the file.

But if you are wanting to have many people write to a file, then using a shelled redirected ">>" ECHO or the INI type output of writeprofilestring() would be the way to go.

also, using the open() command will load the entire document into memory, if the document is small, there will be very little speed difference, but if it is a large file (500m to a gig) then the

ECHO "stuff" >> largefile.txt

would be faster.

Bryce

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1046 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.055 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org