Page 1 of 1 1
Topic Options
#191235 - 2008-12-17 04:24 AM Assign command line result to kix variable
oneill Offline
Fresh Scripter

Registered: 2005-03-24
Posts: 27
Loc: Australia
I'm running a kix script and using %comspec% to run a command and I would like to take the result of that command and assign it to a kix variable?

How would I do this?

Top
#191236 - 2008-12-17 04:39 AM Re: Assign command line result to kix variable [Re: oneill]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Take a look at the WSHPipe() UDF in the UDF forum.
_________________________
There are two types of vessels, submarines and targets.

Top
#191240 - 2008-12-17 05:19 AM Re: Assign command line result to kix variable [Re: Sealeopard]
oneill Offline
Fresh Scripter

Registered: 2005-03-24
Posts: 27
Loc: Australia
Hi Sealoepard,

Thanks for the help. I tried the udf you suggested but couldn't get it to work. Here is the command I am running,

Shell "%comspec% /c msnuser.exe email@hotmail.com"

This returns a number that I would like to assign to a kix variable. However I can't work out how to do it.

Thanks

BTW, the msnuser.exe is a custom exe that takes an email address and calculates your MSN ID number.


Edited by oneill3 (2008-12-17 05:23 AM)

Top
#191241 - 2008-12-17 05:31 AM Re: Assign command line result to kix variable [Re: oneill]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
Try

$returnvalue=wshpipe("msnuser.exe email@@hotmail.com")

or some variation of that in between the quotes.

@ is a reserved character in Kix.

You could also use setoption("nomacrosinstrings","on") if you want to use a single @.
_________________________
(... better days ahead)

Top
#191244 - 2008-12-17 06:45 AM Re: Assign command line result to kix variable [Re: Allen]
oneill Offline
Fresh Scripter

Registered: 2005-03-24
Posts: 27
Loc: Australia
Hi Allen,

This still isn't working as expected. It is outputting the result to the screen, but its not being assigned to the variable, its empty.

any other suggestions?

Thanks.


Edited by oneill3 (2008-12-17 06:46 AM)

Top
#191246 - 2008-12-17 07:47 AM Re: Assign command line result to kix variable [Re: oneill]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
Try this:

Make sure to paste the UDF to the bottom of the script:
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=83201#Post83201

 Code:
$returnvalue=wshpipe("msnuser.exe email@@hotmail.com",1)
for each $line in $returnvalue
  ? "[" + $line + "]"
next


If you read the header of wshpipe, it returns an array. One way to see the contents of an array is to loop through it. Once you know what line the value you want is on, subtract one from it (because arrays are zero based) and then you can do it in one step:

 Code:
$returnvalue=wshpipe("msnuser.exe email@@hotmail.com",1)[linenumber-1 inhere]
_________________________
(... better days ahead)

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
1 registered (mole) and 2107 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.059 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

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