text on stdout

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
yuvaraj
Newbie
Posts: 5
Joined: Tue Jun 16, 2009 2:32 pm

text on stdout

Post by yuvaraj » Fri Jun 19, 2009 10:22 am

hi,

I am trying to print a text on console from where I am executing the 'scp' script using command line. Here is the sample, that I got it from the forum:

----------------------
GetWindowProcess>C:\WINDOWS\system32\cmd.exe,pid,pname

LibFunc>kernel32,AttachConsole,aok,pid
LibFunc>kernel32,GetStdHandle,console,hwnd,-11

Let>Message=Hello World%CRLF%
Length>Message,LenM
LibFunc>kernel32,WriteConsoleA,wcres,consolehwnd,Message,LenM,0,0
------------------------------
saved as sample.scp

When I run in command prompt
>msched.exe sample.scp

"Hello World" gets printed after the execution terminates. It has forked a separate process background.

I want to make it like, start the program wait for "hello World" to print and at the end terminate the program. Can someone help me wat changes to make in the above code.

Thanks
yuvaraj.

This code works

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Compiled scripts can write to STDOUT

Post by gdyvig » Fri Jun 19, 2009 11:06 am

Hi yuvaraj,

If you have the Pro version 11 you can compile the script as a console application and write to STDOUT using the functions SOWrite and SOWriteLn. Only compiled scripts can do this. Possibly you will not need the LibFunc.

See:

http://www.mjtnet.com/usergroup/viewtop ... teconsolea

Gale

yuvaraj
Newbie
Posts: 5
Joined: Tue Jun 16, 2009 2:32 pm

Post by yuvaraj » Fri Jun 19, 2009 12:23 pm

Thanks a lot for the effort Gale.

But, I am trying to print the text using the uncompiled script itself. I will be editing the script so many times. Do you have any ideas in which I can do without making the 'exe' file.

User avatar
JRL
Automation Wizard
Posts: 3518
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Jun 19, 2009 12:31 pm

I may be missing something but a simple Send> function works for me. If I run the following in a script from a DOS command line, the text will be printed in the window. Granted if you press enter the text will be executed but it nonetheless displays.

Code: Select all

Send>Hello World

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts