Page 1 of 1 1
Topic Options
#162426 - 2006-05-24 05:34 PM Using WshPipe output
operez Offline
Getting the hang of it

Registered: 2003-08-08
Posts: 75
I have a VBScript that will tell me what server a user is logged into, in the form of UserName:ServerName. I want to use that information in a script, so I setup the following:

Code:

$rc=split("WshPipe("cscript //nologo C:\WhereIs.wsf operez",1)",":")
? $rc(0)
? $rc(1)

Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
Dim $oExec, $Output
$oExec = CreateObject("WScript.Shell").Exec($ShellCMD)
If Not VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf
$Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll
If Not $NoEcho $Output Endif
$WshPipe=Split(Join(Split($Output,CHR(13)),''),CHR(10))
Exit($oExec.ExitCode)
EndFunction



I am getting an “Error in expression: this type of array not supported in expressions.! Line: 2” error message. It’s been awhile since I used kix, but what am I doing wrong?

Top
#162427 - 2006-05-24 05:40 PM Re: Using WshPipe output
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Without knowing what your VBScript outputs and why you do a Split() on the array output from WSHPipe(), there is not much we can do.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#162428 - 2006-05-24 06:00 PM Re: Using WshPipe output
operez Offline
Getting the hang of it

Registered: 2003-08-08
Posts: 75
The script output is UserName:ServerName and I want to split the results at the colon onto two elements in the array, the first is the UserName and the second is the ServerName.

For the purpose of just testing my logic, I was outputting the results of each element to the screen.

Top
#162429 - 2006-05-24 06:21 PM Re: Using WshPipe output
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL

$return = WshPipe("cscript //nologo C:\WhereIs.wsf operez",1)
for each $line in $return
if instr($line,':')
$rc=split($line,":")
? $rc(0)
? $rc(1)
else
? 'no : in line -> ' + $line
endif
next
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#162430 - 2006-05-24 06:55 PM Re: Using WshPipe output
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

The script output is UserName:ServerName and...



I did not ask what the script output was, you already told us that. I asked what the WSHPipe() output was and why you were trying to Split() an array.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#162431 - 2006-05-24 08:40 PM Re: Using WshPipe output
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
and ..
Code:
? $rc(0)
? $rc(1)

should be
Code:
?$rc[0]
?$rc[1]



A case of () vs []
_________________________
Today is the tomorrow you worried about yesterday.

Top
#162432 - 2006-05-24 09:11 PM Re: Using WshPipe output
operez Offline
Getting the hang of it

Registered: 2003-08-08
Posts: 75
Les,

I had may last cup of coffee almost 6 hours ago and I’ve had a big lunch, so forgive me if I don’t understand your question. Because, the output from my VBScript is the user name and the server name, separated by a colon. Wouldn’t that also be the output of WshPipe function?

I don’t get to script much and I don’t get out very often, but you’ve made me see the error in my ways. I now realize that I was trying to split an array, when the split command only works on strings.

Radimus,

I had to change
Code:

? $rc(0)
? $rc(1)


to
Code:

? $rc[0]
? $rc[1]


to make this script work. I really appreciate your help.

Top
#162433 - 2006-05-24 09:18 PM Re: Using WshPipe output
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

but you’ve made me see the error in my ways



then, mission accomplished.

sorry for the cryptic lesson.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

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 837 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.059 seconds in which 0.026 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