You need to make sure your app_name.exe works with a stdin file before 
trying to run it with a stdin file via STAF.

Can you run your command via the command line specifying stdin file 
C:\STAF\input.out?

"C:\appDir\app_name.exe" < C:\STAF\input.out

If you can't do that, then you can't run it that way using a stdin file 
via STAF either.

I don't know how your app_name.exe executable is reading stdin (e.g. 
reading by word, line, etc) as you have not provided the code for your 
app_name.exe file.

Note that the PROCESS service is simply trying to run your command.  It's 
not changing anything in your command.

There is a note in section "8.12.2 Start" in the STAF User's Guide about a 
PROCESS START request (which is what a <process> element is submitting). 
It says:

1.      On Windows systems, if you are redirecting stdin/out/err and are 
not using SAMECONSOLE, it is recommended that you redirect all three 
input/output streams. If one or two streams are redirected, but not all 
three, the non-redirected streams will not be available to the 
application. For example, if stdout and stderr are redirected, but not 
stdin, then the application will receive errors if it tries to read from 
standard input. As another example, if stdin and stdout are redirected, 
but not stderr, then you will not see any of the standard error output 
displayed in the console window. This problem only occurs when using 
NEWCONSOLE, which is the default. You may freely redirect any combination 
of stdin, stdout, and stderr when using SAMECONSOLE. This problem is due 
to a known limitation in the Windows API. 

This is probably why you had a problem if you removed the <stdin> element 
from the process, since you are redirecting stdout and stderr.  Note that 
you could use the SAMECONSOLE option to prevent this problem if you remove 
the stdin option.  For a <process> element, you would specify the <console 
use="'same'"/> within the <process> element, after the <returnstdout/> 
element.

--------------------------------------------------------------
Sharon Lucas
IBM Austin,   luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313




Mandar <m_gokhal...@yahoo.com> 
04/03/2009 02:06 PM
Please respond to
m_gokhal...@yahoo.com


To
Sharon Lucas/Austin/i...@ibmus
cc

Subject
Re: [staf-users] Question regarding STAF/STAX







Hi Sharon,

On another side note, I do not need to have any interaction with the 
process. I can mention all the commands that I need to send to the process 
in the "input.out" file.

(Contents of "input.out)

   print "hello"
   quit

The process seems to read ONLY the first WORD...It just sends "print" as a 
command to the executable to which the applications responds with an error 
message saying that it is an incomplete command. I can see the word 
"print" being sent to the process in "abc.out".

However, if I have the contents of the file as:

(Contents of "input.out)

    list
    quit

I can see the response to the command "list" getting printed in abc.out. 
But it never sends the "quit" command; it keeps sending the "list" command 
to the application repeatedly. What could be the problem? A bug in process 
service?

Please let me know if you need any additional information.

Thanks,
Mandar

--- On Fri, 4/3/09, Sharon Lucas <luc...@us.ibm.com> wrote:
From: Sharon Lucas <luc...@us.ibm.com>
Subject: Re: [staf-users] Question regarding STAF/STAX
To: m_gokhal...@yahoo.com
Date: Friday, April 3, 2009, 2:38 PM


I don't think you understood what I was saying.  I tried to explain that 
you could use a stdin file OR use the QUEUE service.  Not use both, as 
your example is showing. 
  
First, what is the command that you are trying to run via the <process> 
element , e.g what is the .exe file?  Is this an executable that you 
wrote?  Do you know what it does?  Does it read data from a stdin file? If 
you run this command from the command line, without STAF or STAX involved, 
what is the exact command that you are  running?  Are you inputting a 
stdin file to it?  For example, is this how you run it from the command 
line without STAF (substituting the correct values for appDir and 
app_name)? 

C:>\appDir\app_name.exe < C:\STAF\input.out 

If it's not, then running this command via STAF/STAX is not going to work 
either. 

Also, if you can't change this executable to create a STAF handle and to 
submit QUEUE GET requests, then using the Queue approach won't work.   

--------------------------------------------------------------
Sharon Lucas
IBM Austin,   luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313




Mandar <m_gokhal...@yahoo.com> 
04/03/2009 01:26 PM 

Please respond to
m_gokhal...@yahoo.com



To
Sharon Lucas/Austin/i...@ibmus 
cc

Subject
Re: [staf-users] Question regarding STAF/STAX









Hi Sharon,

Thank you very much for your prompt reply. Here is the process code that I 
am using:

-----------------------------------

<process name="'app_process'">

<location>machine</location>
<command>'%s/%s.exe' % (app_dir, app_name)</command>
<parms>''</parms>
<envs>EnvVarList</envs>
<focus mode="'minimized'"/>
<stdin>'C:/STAF/input.out'</stdin>
<stdout mode="'replace'">'%s/abc.out' % (dir)</stdout>
<stderr mode="'stdout'"/>
<returnstdout/>

<process-action>
<sequence> 
<stafcmd> 
<location>machine</location> 
<service>'QUEUE'</service> 
<request>'QUEUE HANDLE %s "first message"' % (STAXProcessHandle)</request>
</stafcmd>
</sequence>
</process-action> 

</process>

-------------------------------------------------------

A few points I need to mention/ask are as follows:

(1) Can I use the "QUEUE" only in the <process-action> element?

(2) The stdin file (input.out) is totally empty - If I do not mention the 
<stdin> element in the above code, the stdout file that is generated 
(abc.out) has a line "stack manager error" filled up for more than 50,000 
lines! - Do you know what might be the reason?

(3) When I start the process, I can see the stdout and stderr getting 
written into the provided output file (abc.out). However, when I send a 
message using QUEUE, will the response to that command be appended in 
"abc.out"? For e.g.: If I send a command "print hello" to which the 
process prints the word "hello" as a response, would/should the word 
"hello" be appended to "abc.out"?

(4) Is there a way by which the user commands that I send to the process' 
QUEUE can be appended in "abc.out" along with the response to the command, 
like this...

(Contents of abc.out)

   ..
   ..
   > print hello (USER INPUT)
   hello (RESPONSE TO THE ABOVE COMMAND)
   ..
   ..

-------------------------------------------------------

To put it in very simple terms, what I am trying to achieve is this: Start 
a process and send 3-4 commands to it. I am not even concerned with the 
process's response to my commands except that I need to log EVERYTHING 
that the process spits out in "abc.out".

If you could help me with the above questions, that would really great. 
And yes, once again, thank you very much for such a detailed reply to my 
question. I really appreciate it.

Take care,
Mandar

--- On Fri, 4/3/09, Sharon Lucas <luc...@us.ibm.com> wrote: 
From: Sharon Lucas <luc...@us.ibm.com>
Subject: Re: [staf-users] Question regarding STAF/STAX
To: m_gokhal...@yahoo.com
Cc: staf-users@lists.sourceforge.net
Date: Friday, April 3, 2009, 1:38 PM


Hi Mandar, 

You can use the stdin option to specify the name of an input file for the 
process, but this input file must contain all the commands you want the 
process to run BEFORE you start the process.  Using a stdin file to pass 
data to your process does not let you do this interactively.  If you have 
all the commands in your stdin file before the process is started, then 
your process can read the commands from the stdin file.  If your process 
is reading the same line from the stdin file repeatedly and writing it to 
a log file, then that is an error in your process's code.  Since you 
didn't post your code, I can't comment on what you're doing wrong.  If you 
post your code, then perhaps I could tell you what you're doing wrong -- 
but note that this wouldn't be a STAF-specific question.  It's simply a 
question of how to read data from a stdin file. 

If you want to send commands to the process interactively (i.e. as if you 
were typing commands to an interactive CLI), then you should look at using 
the STAF QUEUE service instead of providing the commands via a stdin file. 
 The QUEUE service (as documented in the STAF User's Guide) provides a 
QUEUE request that lets you send messages to a STAF handle's queue and 
provides a GET request that lets you get messages off a STAF handle's 
queue.  So, you could use a <stafcmd> to submit a QUEUE request to the 
QUEUE service, specifying the process's handle number (or handle name) and 
for the MESSAGE option, specify a command to send to the process.  Then, 
your process can register with STAF (e.g. create a STAF handle) and then 
receive messages on its queue by submitting a GET request to the QUEUE 
service. 

Note that you can search the STAF forums and/or mailing list and find 
examples of how to do this using the STAF QUEUE service. 

For example, see the posting on the STAF Help Forum at 
http://sourceforge.net/forum/message.php?msg_id=5064397 titled "Queue/Get 
messages from STAX" that provides an example of using a starting a process 
(a Java program) within a STAX job and from its <process-action> 
sub-element, use a <stafcmd> command to send messages to the process's 
queue. 

Other postings that might interest you include: 
- http://sourceforge.net/forum/message.php?msg_id=4552372 
- http://sourceforge.net/forum/message.php?msg_id=5790425 

--------------------------------------------------------------
Sharon Lucas
IBM Austin,   luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313




Mandar <m_gokhal...@yahoo.com> 
04/03/2009 11:49 AM 

Please respond to
m_gokhal...@yahoo.com



To
staf-users@lists.sourceforge.net 
cc

Subject
[staf-users] Question regarding STAF/STAX











Hello,

My name is Mandar. I am not sure if this is the best way to ask a 
question/to reach you. It would be really great if I could get some 
feedback with the problem that I am trying to solve.

I am running a process using the <process> element and storing the 
"stdout" and "stderr" in a log file. Once the process has started, I need 
to send commands to the process using <stafcmd> element. I read about 
"stdin" option (in a process) where we can specify a input file to pass 
commands to the process. The problem with that is: Let's say that the file 
contains only 1 command (print hello), the process takes input from the 
file but does it "repeatedly" and fills the log file (thousands of lines) 
with the word hello!

I am really stuck and would appreciate any kind of help. Please let me 
know if you need any additional information.

Thanks,
Mandar


------------------------------------------------------------------------------
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users



------------------------------------------------------------------------------
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to