Hi!
Is it possible to read the output from a command line program directly into a variable?
And not like this:
Run Program>cmd /c "dir >c:\dirout.txt"
ReadFile>c:\dirout.txt,dirout
This is what I do now (the dir command is jus an example.)
I.e
the output from
Run Program>cmd /c "dir"
is directly read by MS into the variable dirout.
That would be helpful!
Thanks!
Reading output from command line pogram.
Moderators: Dorian (MJT support), JRL
-
- Pro Scripter
- Posts: 149
- Joined: Tue Mar 23, 2004 9:11 pm
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Hi,
No. The only thing I can think of is to have a .bat file redirect stdout to a file, read the file into a variable and than pass the content of that to Macro Scheduler on the command line.
But that's probably no less work than outputting to a file and having your macro read the file. Just depends at which end you want to do the work.
No. The only thing I can think of is to have a .bat file redirect stdout to a file, read the file into a variable and than pass the content of that to Macro Scheduler on the command line.
But that's probably no less work than outputting to a file and having your macro read the file. Just depends at which end you want to do the work.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Just curious about why? Are you trying to avoid writing a file that may need to be deleted or moved? Trying to make sure that there is no trace left behind? There may be ways to accomplish that without creating a file or leaving a trail.
Can you explain why the need, what you are trying to accomplish with this methodology? One extra line in a script does not seem to be a big penalty.
Can you explain why the need, what you are trying to accomplish with this methodology? One extra line in a script does not seem to be a big penalty.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
-
- Pro Scripter
- Posts: 149
- Joined: Tue Mar 23, 2004 9:11 pm
Hi!
I need to run a third party command line program and get the output from that program into the script
1. It is a multi user program. I.e it is NOT run on a single PC. It is run from a webpage. So if two users use the same function and one creates the file at the same time as someone else is deleting it, You have problem. (as it is now i create unique filenames)
2. Writing to a file slows things down. It is faster to write directly to RAM.
Thanks for Your interest!
I need to run a third party command line program and get the output from that program into the script
1. It is a multi user program. I.e it is NOT run on a single PC. It is run from a webpage. So if two users use the same function and one creates the file at the same time as someone else is deleting it, You have problem. (as it is now i create unique filenames)
2. Writing to a file slows things down. It is faster to write directly to RAM.
Thanks for Your interest!
Found the answer
Try this.
Code: Select all
VBSTART
Function GetIn()
Dim WshShell, oExec, input
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("cmd /c dir")
input = ""
Do While True
If Not oExec.StdOut.AtEndOfStream Then
input = input & oExec.StdOut.Read(1)
If oExec.StdOut.AtEndOfStream Then Exit Do
End If
Loop
GetIn = input
End Function
VBEND
VBEval>GetIn,result
MessageModal>result
-
- Pro Scripter
- Posts: 149
- Joined: Tue Mar 23, 2004 9:11 pm
-
- Pro Scripter
- Posts: 149
- Joined: Tue Mar 23, 2004 9:11 pm