Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing an RSH external command 1

Status
Not open for further replies.

JPJeffery

Technical User
May 26, 2006
600
GB
Hello, chaps!

OK, I need to run a UNIX command using RSH and grab the output to a file for further manipulation within my vbscript. Specifically the command is
Code:
rsh 172.16.13.200 df -h >%temp%\san.out

I've got the right syntax from the command prompt but can't seem to get it to work within the vbscript:
Code:
ExecCMD = "rsh " & strSAN_IP & " df -h | findstr /V /c:"".snapshot"">" & strSAN_Report '%temp%\san.out"
Set objExec = objWSHShell.Exec(ExecCMD)"

Have also tried it as
Code:
ExecCMD = "rsh " & strSAN_IP & " df -h | findstr /V /c:"".snapshot"">%temp%\san.out"
Set objExec = objWSHShell.Exec(ExecCMD)"
I am using Option Explicit, so typos have pretty much been disregarded as the cause, and strTemp has been correctly populated with [tt]strTemp = objWSHShell.ExpandEnvironmentStrings("%TEMP%")[/tt] so all the paths, including for strSAN_Report and strSAN_IP seem to be correct too.

Here's the whole sub-routine:
Code:
Sub RunCheckSAN()
    strTitle = "SAN Storage"
    wscript.echo strBorder
    strEcho = "Checking SAN Storage" ' & vbCrLf
    Call NextHeader(strTitle,strEcho)
	Dim strSAN
	Dim strSAN_IP
	Dim strSAN_Name
	Dim arrSAN
	Dim strSAN_Report
	strSan_Report = strTemp & "\san.out"
	wscript.echo " strSan_Report = " & strSan_Report
    Dim ExecCMD

    For Each strSAN in arrSANs
		
		if objFSO.FileExists(strSan_Report) then
			wscript.echo " Deleting " & strSan_Report & "..."
			objFSO.DeleteFile strSan_Report
		end if
		
		arrSAN  = split(strSAN,",")
        strSAN_IP = arrSAN(0)
        strSAN_Name = arrSAN(1)
		wscript.echo " strSAN_IP = '" & strSAN_IP & "'"
		ExecCMD = "rsh " & strSAN_IP & " df -h | findstr /V /c:"".snapshot"">" & strSAN_Report '%temp%\san.out"
		Set objExec = objWSHShell.Exec(ExecCMD)
		'wscript.sleep 2000
		
		if objFSO.FileExists(strSan_Report) then
			Wscript.echo " Found " & strSan_Report & "...analysis for " & strSAN_Name & " will commence here..."
			Set objSAN_Report = objFSO.OpenTextFile(strSan_Report, ForReading)
		else
			Wscript.echo " Couldn't find " & strSan_Report & "! Please check " & strSAN_Name & " storage manually!"
		end if

	Next
End Sub
What am I doing wrong?


JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, and so on)[/small]
 
Replace this:
"rsh "
with this:
"CMD /C rsh "

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
D'Oh!

JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, and so on)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top