HP3000-L Archives

July 2007, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
okappert <[log in to unmask]>
Reply To:
Date:
Fri, 6 Jul 2007 10:02:47 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (159 lines)
Roy:

I am not sure this is what you need but try "|" as the pipe action.

Regards, Olav.

Roy Brown wrote:

> In message 
> <[log in to unmask]>, 
> John K. <[log in to unmask]> writes
>
>> It has been quite a while since I've had to do a lot with the Windows 
>> command line, and now I find I can't remember certain things, such as...
>>
>> I need to create a .bat file that contains a command to invoke a php 
>> script multiple times, with the "stdin" for each invocation of the 
>> php script immediately following the command invoking the script (ah, 
>> how easy it was to do such things in MPE).  Below is an example of 
>> what the .bat file structure would be:
>>
>> c:\php\php.exe [php_script_name] 
>> [?_something_to_tell_DOS_stdin_data_follows]
>> [line_0_of_data]
>> [line_1_of_data]
>> [line_2_of_data]
>> ...
>> [line_n_of_data]
>> [eod_mark-though_it_was_ctrl_z]
>> c:\php\php.exe [php_script_name] 
>> [?_something_to_tell_DOS_stdin_data_follows]
>> [line_0_of_data]
>> [line_1_of_data]
>> [line_2_of_data]
>> ...
>> [line_n_of_data]
>> [eod_mark-though_it_was_ctrl_z]
>> c:\php\php.exe [php_script_name] 
>> [?_something_to_tell_DOS_stdin_data_follows]
>> [line_0_of_data]
>> [line_1_of_data]
>> [line_2_of_data]
>> ...
>> [line_n_of_data]
>> [eod_mark-though_it_was_ctrl_z]
>>
>> etc. - you get the point.
>> I tried using "<" for the 
>> "[?_something_to_tell_DOS_stdin_data_follows]" but that didn't work.  
>> I can get it to work if the data is in an external file, but that 
>> won't work for this application.  I thought CTRL-Z was the "end of 
>> data" but that just seems to cause the command window to hang.
>>
>> I guess I'm Googling the wrong keywords as I'm not finding what I'm 
>> looking for.
>>
>> Any suggestions or assistance are greatly appreciated!
>>
>> John (running late to pick up my children for a movie!)
>>
>> *** When replying to this message, please do not delete these ***
>> *** signature lines. Otakon Katsucon HP3000-L @classiccmp.org ***
>> *** DigitalCosplay.com    JohnKorbPhoto.com     JohnPKorb.com ***
>
>
> Hi John
>
> I don't know if you got any replies privately.
>
> But if not, I can at least share my ignorance with you, given that I 
> know nothing of php; and also possibly not enough of how MPE works in 
> this area :-)
>
> If I don't miss my guess on MPE, then if php.exe was an MPE program 
> running in a jobstream, it wouldn't be MPE passing the subsequent 
> lines to php exactly.
>
> Rather, they would only be passed to php if it specifically requested 
> them, line by line; though then, as the default feed for the request 
> would be from STDIN, and the datastream itself would be STDIN, MPE 
> would then pass the lines in one by one.
>
> I hope this does not sound like splitting hairs... but it has two 
> implications.
>
> The first is that only as many lines would be passed in as php.exe 
> (via its script) requested. So if php.exe requested less lines than 
> there were of data, and then quit, MPE would try to execute any 
> remaining lines of data as commands.
>
> And conversely, if php.exe requested more lines, then the later php 
> command lines themselves would be passed in.
>
> So, to make the above work on MPE. with a possibly variable number of 
> lines to be fed into each php invocation, you'd have to have a loop in 
> your php code, and some sort of closing token ( for which CTRL-Z might 
> be fine) that told the php code to stop executing and to quit.
>
> I don't think it's going to be much different from this under DOS for 
> you. And I don't think you can pipe multiple lines into a DOS command 
> in quite the way you seem to want to above.
>
> I see two choices: firstly, can you build the file you need on the 
> fly? You say an external file won't work, but not exactly why).
>
> Taking one invocation of PHP, above:
>
> c:\php\php.exe [php_script_name] 
> [?_something_to_tell_DOS_stdin_data_follows]
> [line_0_of_data]
> [line_1_of_data]
> [line_2_of_data]
> ...
> [line_n_of_data]
> [eod_mark-though_it_was_ctrl_z]
>
> can you invert and extend this, thus:
>
> [line_0_of_data] > tempfile
> [line_1_of_data] >> tempfile
> [line_2_of_data] >> tempfile
> ...                    >> tempfile
> [line_n_of_data] >> tempfile
>
> c:\php\php.exe [php_script_name] < tempfile
>
> and you may or may not need:
>
> [eod_mark (some convention, perhaps ctrl_z] >> tempfile
>
> depending on whether you need something to tell the invocation of php 
> to quit or not - if it's a variable number of line, you probably will, 
> though).
>
> This can all still be done on the fly, but requires the php invocation 
> to follow, not precede, the data, and for the >(>) tempfile to be 
> appended to each data line.
>
>
> The second possible option, which would allow you to keep the format 
> in which, is to explicitly tell php to read the STDIN; it can do this, 
> but needs to be told to, apparently:
>
> http://uk2.php.net/manual/en/features.commandline.php
>
> where it describes:
>
> If you want to read a single line from stdin, you can use
> <?php
> $line = trim(fgets(STDIN)); // reads one line from STDIN
> fscanf(STDIN, "%d\n", $number); // reads number from STDIN
> ?>
>
> I hope this helps. As I said above, I would not be my own first choice 
> of php expertise :-)

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2