How to read in data from the command window?

This is a discussion on How to read in data from the command window? within the REXX forums in Programming Languages category; How do you pull in data issued in the cmd window Example my REXX program issues "ADDRESS CMD DIR" how do I capture the response as data to be used later in the program? Is the response read as one stream or individual lines. Thanks in advance....

Go Back   Application Development Forum > Programming Languages > REXX

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 07-21-2008, 08:24 PM
globaloney
Guest
 
Default How to read in data from the command window?

How do you pull in data issued in the cmd window
Example my REXX program issues "ADDRESS CMD DIR"
how do I capture the response as data to be used later in the program?
Is the response read as one stream or individual lines.
Thanks in advance.
Reply With Quote
  #2  
Old 07-21-2008, 08:35 PM
globaloney
Guest
 
Default Re: How to read in data from the command window?

On Jul 21, 7:24*pm, globaloney <jgol...@excite.com> wrote:
> How do you pull in data issued in the cmd window
> *Example *my REXX program issues "ADDRESS CMD DIR"
> how do I capture the response as data to be used later in the program?
> Is the response read as one stream or individual lines.
> Thanks in advance.


Sorry,I forgot to say I'm running Windows OS.
Reply With Quote
  #3  
Old 07-21-2008, 09:45 PM
Arthur T.
Guest
 
Default Re: How to read in data from the command window?

In
Message-ID:<87322844-a0d5-435c-88eb-264c0833c194@d77g2000hsb.googlegroups.com>,
globaloney <jgolano@excite.com> wrote:

>On Jul 21, 7:24*pm, globaloney <jgol...@excite.com> wrote:
>> How do you pull in data issued in the cmd window
>> *Example *my REXX program issues "ADDRESS CMD DIR"
>> how do I capture the response as data to be used later in the program?
>> Is the response read as one stream or individual lines.
>> Thanks in advance.

>
>Sorry,I forgot to say I'm running Windows OS.


You also forgot to specify your flavor or REXX. When I ask
something that even might be related to my OS, REXX, or level, I
run this and show the appropriate parts of the output:

<code>
say ''
parse source a
say "parse source output:" a
say "address():" address()
say ''
parse version b
say "parse version output:" b

call rxfuncadd 'sysloadfuncs','RexxUtil','sysloadfuncs'
call sysloadfuncs
say "McPhee's RegUtil (aka RexxUtil)" SysUtilVersion()

call rxfuncadd 'w32loadfuncs','W32util','w32loadfuncs'
call w32loadfuncs
parse value w32version() with ver file
say "McPhee's W32Util" ver

"ver"
</code>

However, to answer your question, in Regina, you'd code
something along the lines of:
address system 'dir' with output replace stem dir1.

--
Arthur T. - ar23hur "at" intergate "dot" com
Looking for a z/OS (IBM mainframe) systems programmer position
Reply With Quote
  #4  
Old 07-21-2008, 10:44 PM
globaloney
Guest
 
Default Re: How to read in data from the command window?

On Jul 21, 7:24*pm, globaloney <jgol...@excite.com> wrote:
> How do you pull in data issued in the cmd window
> *Example *my REXX program issues "ADDRESS CMD DIR"
> how do I capture the response as data to be used later in the program?
> Is the response read as one stream or individual lines.
> Thanks in advance.


I am using ooREXX
Reply With Quote
  #5  
Old 07-21-2008, 11:47 PM
globaloney
Guest
 
Default Re: How to read in data from the command window?

On Jul 21, 7:24*pm, globaloney <jgol...@excite.com> wrote:
> How do you pull in data issued in the cmd window
> *Example *my REXX program issues "ADDRESS CMD DIR"
> how do I capture the response as data to be used later in the program?
> Is the response read as one stream or individual lines.
> Thanks in advance.


I did get the following code to run however it generates errors in the
cmd window.

/*********************************/
rxqueue('delete','jgq')
rxqueue('create','jgq')
rxqueue('set','jgq')
cmdstr = "dir *.txt"
ADDRESS CMD cd prf
ADDRESS CMD cmdstr"| rxqueue jgq "
Do queued()
pull qline
got=got+1
/************************************************** ********/
pos1 = pos('~', qline)
pos2 = pos('.TXT',qline)
if pos1 > 0 and pos2 > 0 then do
tr=pos1-2
orse=substr(qline,tr,12)
call LINEOUT FOLENAME, orse
end
CALL LINEOUT (FOLENAME) /* CLOSE */

/**************************************************/
I did get the above code to run, however it generates the
following(non impacting) error messages in the command window;

'0' is not recognized as an internal or external command,operable
program or batch file.
'JGQ' is not recognized as an internal or external command,operable
program or batch file.
'SESSION' is not recognized as an internal or external
command,operable program or batch file.

Is there a way to suppress the messages FMI?

Reply With Quote
  #6  
Old 07-22-2008, 12:46 AM
Phil
Guest
 
Default Re: How to read in data from the command window?


"globaloney" <jgolano@excite.com> wrote in message
news:77d535c0-d28e-4e54-923c-345c19ca9f79@8g2000hse.googlegroups.com...
On Jul 21, 7:24 pm, globaloney <jgol...@excite.com> wrote:
> How do you pull in data issued in the cmd window
> Example my REXX program issues "ADDRESS CMD DIR"
> how do I capture the response as data to be used later in the program?
> Is the response read as one stream or individual lines.
> Thanks in advance.


I did get the following code to run however it generates errors in the
cmd window.

/*********************************/
rxqueue('delete','jgq')
rxqueue('create','jgq')
rxqueue('set','jgq')
cmdstr = "dir *.txt"
ADDRESS CMD cd prf
ADDRESS CMD cmdstr"| rxqueue jgq "
Do queued()
pull qline
got=got+1
/************************************************** ********/
pos1 = pos('~', qline)
pos2 = pos('.TXT',qline)
if pos1 > 0 and pos2 > 0 then do
tr=pos1-2
orse=substr(qline,tr,12)
call LINEOUT FOLENAME, orse
end
CALL LINEOUT (FOLENAME) /* CLOSE */

/**************************************************/
I did get the above code to run, however it generates the
following(non impacting) error messages in the command window;

'0' is not recognized as an internal or external command,operable
program or batch file.
'JGQ' is not recognized as an internal or external command,operable
program or batch file.
'SESSION' is not recognized as an internal or external
command,operable program or batch file.

Is there a way to suppress the messages FMI?
================================================== ===========

If you use syntax like: "func(parms)" you are invoking a function and it
will return
a result that needs to be handled so you would use something like: "rc =
func(parms)".
You can use or ignore the value of the var rc.

If you don't want to return a value and/or don't want it, use this: "call
proc parms".
This can also return a result that you can find in the var "result".

When you don't handle the function result, it is passed to the OS and it
doesn't understand
what it sees and offers the messages you see. These are Windows messages.

Phil
---





Reply With Quote
  #7  
Old 07-22-2008, 10:16 AM
Michael Lueck
Guest
 
Default Re: How to read in data from the command window?

globaloney wrote:
> How do you pull in data issued in the cmd window
> Example my REXX program issues "ADDRESS CMD DIR"


If you are specifically looking for solutions to get the listing of a directory, there is a very nice API in ooRexx named SysFileTree which returns a stem variable of results.

Others, I see, have answered your "screen scrap" question.

--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 08:45 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.