Solved

How do I send text to stdout?

Posted on 2003-12-02
11
8,844 Views
Last Modified: 2012-05-04
How do I send text to stdout?

Thanks.
0
Comment
Question by:turn123
  • 5
  • 5
11 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9858848
0
 
LVL 11

Author Comment

by:turn123
ID: 9859086
Line three character twelve gives and error "Syntax error".  I'm trying to write a VBScript.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9859635
To stdout

Just use

Wscript.Echo

example, read and write from stdout (cmd.exe)

http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/scrguide/sas_wsh_pkoy.asp

0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 11

Author Comment

by:turn123
ID: 9861277
It looks like that article captures the stdout of another program.  I want to be able to write to stdout so I can caputure the output with another program.

Something like

out = "text"
stdout.write(out).

I can't figure out how to do it though.

Thanks for your help.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9861312
Is it just

Wscript.Echo
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9861315
ie

out = "text"
Wscript.Echo out
0
 
LVL 11

Author Comment

by:turn123
ID: 9861857
That brings up a message box that says text regardless of how the program is called.  If you call it through the command prompt you get a message box rather then text.

I need it to send the text to the standerd out that can be read other programs.
0
 
LVL 9

Expert Comment

by:TooKoolKris
ID: 9863015
Here is some code you can actually use that does what you requested. It's for .vbs a script that runs IPConfig.exe, and then echoes only the line of output that includes the IP address of the local computer. This script must be run from the command prompt(cscript) as all scripts that have STD objects must be.

Set objShell = WScript.CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec("%comspec% /c ipconfig.exe")

Do Until objExecObject.StdOut.AtEndOfStream
    strLine = objExecObject.StdOut.ReadLine()
    strIP = Instr(strLine,"Address")
    If strIP <> 0 Then
        Wscript.Echo strLine
    End If
Loop
0
 
LVL 11

Author Comment

by:turn123
ID: 9863225
Thank you.

I still don't see how to get it to print my text "test".

Could you show me how please?

Thanks.
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 100 total points
ID: 9866096
Try this


in tt.vbs

Set objShell = WScript.CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec("%comspec% /c c:\temp\aa.vbs")

Do Until objExecObject.StdOut.AtEndOfStream
    strLine = objExecObject.StdOut.ReadLine()
    Wscript.Echo strLine
Loop


in aa.vbs

Wscript.Echo "test"
Wscript.Echo "test1"


When you run tt.vbs, you should see the line show on the cmd
0
 
LVL 11

Author Comment

by:turn123
ID: 9866798
That did it.
Thank you very much.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question