Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I wrote the following VB script in order to run commands from WIN XP on a Linux machine and redirect the output command to out.txt file ( under C:\ )

I don’t understand why output from the command window is not written to out.txt file.

What’s wrong with the line

      Sh.Run "cmd /k  & CMD >> ""C:\out.txt""" , 1, True

My full VB script:

 'TARGET_HOST  - Linux machine

 Const TARGET_HOST = "18.20.183.99"
 const PATH =  "cat /etc/hosts" 
 const LOGIN = "root"
 const PASS = " dingdong "
 Const PLINKPATH="""C:\SPUTNIK\plink.exe"""

 Set Sh = CreateObject("WScript.Shell")

        CMD = " echo y | " &   PLINKPATH  & " -ssh -pw " & PASS & LOGIN & "@" & " "   &  TARGET_HOST & " " & PATH 


 Sh.Run "cmd /k  & CMD >> ""C:\out.txt""" , 1, True

  Set Sh = Nothing
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Right now you are including the CMD variable you created inside the string instead of as a variable.

Try something like:

Sh.Run "cmd /k" & CMD & " >> ""C:\out.txt""" , 1, True

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.