Page 1 of 1 1
Topic Options
#56615 - 2001-06-19 10:27 AM Using Nul output from shell command in script
Anonymous
Unregistered


I remember seeing somewhere a neat script that used a shell command to generate a line of output that was directed to nul. Then the script read that nul data and used it to perform additional tasks. For the life of me, I can't find it on the boards nor anywhere else. Can anyone remember or show me an example?

The idea is to run a DOS/NT command that feeds another command.

Example:

shell "%comspec% /c anycommand.exe > nul"

Do you use readline somehow?

Thanks,

Alex

Top
#56616 - 2001-06-19 11:19 AM Re: Using Nul output from shell command in script
Anonymous
Unregistered


What I do is, send the output to a temp file & read the file in as shown below.

PS. when you have finished doing what you are doing, don't forget to delete the temp output file

Hope it helps . . .

shell '%comspec% /c net user @USERID /domain | find /i "account expires" > c:\expire.dat'

If Open (3,"C:\expire.dat") = 0
$line=ReadLine(3)
While @Error = 0
? "Line Read: [" + $line + "]"
$Expire = substr("$line",30,10)

$x=ReadLine(3)
Loop
EndIf
?"$Expire"

;Closes & Deletes Tempory File
$RC = close(3) del "c:\expire.dat"

Top
#56617 - 2001-06-19 04:50 PM Re: Using Nul output from shell command in script
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
The only shell > nul and using the return code inside Kix that i can think of, is the use of command line programs that set the @error code, one example is the FIND command.

Here is an example using "ping | find" to see if a computer is alive.

code:

$ip = "128.2.0.234"

shell '%comspec% /c ping -n 1 $ip | find /i "TTL" > nul'
select
case @error = 1
"$ip is dead"
case @error = 0
"$ip is alive"
endselect


Bryce

------------------
kix.isorg.net

Top
#56618 - 2001-06-19 05:38 PM Re: Using Nul output from shell command in script
Anonymous
Unregistered


That last one is the one I was thinking of. However, both replies do address the issue I was dealing with. Thanks.

Alex

Top
Page 1 of 1 1


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

Who's Online
0 registered and 1452 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.087 seconds in which 0.065 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