Complex shell pipes to perl? 
Author Message
 Complex shell pipes to perl?

I have a complex 'application' written in ksh. For quite a while I have
been contemplating  converting it to perl (over 200K lines of code!). My
primary reason has been that it may be easier to run on NT (if I chose) and
it would probably be a little faster since there would be a lot fewer
system calls.

However, the primary purpose is to backup system files. I do a lot of pipes
and backgrounding of tasks to run in parallel for performance. I have
looked through the FAQ and tried to keep up once in a while on the WIN32
advances and I have a couple of (what I consider) stumbling blocks.

1) Handling of pipes is not very straightforward...e.g. in shell I do the

func_in ()
        $IN_FUNC        # e.g. dd if=input_file; send output to STDOUT


func_proc ()
        $PROC_FUNC      # e.g. compress; takes STDIN, process, send to STDOUT


func_out ()
        STAT=`$OUT_FUNC`        # e.g "rsh host 'some_script'" whose output shows stat
        [ "$STAT" = "OKEYDOKEY" ] && STAT_OUT=0


and in main for Prog1

$in_proc | $func_proc | $func_out

And then check the STAT_* variables for status of each step of the pipe. (I
have to be able to use  system provided tools for each of the 3 steps in
the pipe above).

Calls several Prog1sin background i.e.
        Prog1 &
        Prog1 &
and checks on them peirodically till done and then gets their status.

Q1: How easy and portable is this in perl? I looked at some pipe examples
that deal with a single pipe and in the foreground. While my brain finally
got around to understanding that, this situation had me overwhelmed not
considering all the cautions about signals etc. that the shell
makes real easy for me.....

Q2) Since Win32 does not support 'fork', is the above situation become so
difficult to manage that it is not worth considering the port?

Q3) Is perl the right choice for this type of app? soemone want to port it
for me for a price? :-)

Any experiences/words of wisdom would be appreciated.

Fri, 16 Jun 2000 03:00:00 GMT  
 Complex shell pipes to perl?


> Hi,
> I have a complex 'application' written in ksh.
> However, the primary purpose is to backup system files.

you may want to check out this free disk archiver:

I've installed it at a former employer's site, and though it didn't work
out of the box, it was a good deal better then rolling my own.

 > Q3) Is perl the right choice for this type of app? soemone want to
port it

> for me for a price? :-)

I may consider it. What are your time constraints and your target


Fri, 16 Jun 2000 03:00:00 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Unable to pipe shell command with perl vars

2. HELP: Piping shell command into perl command?

3. piped open and shell metacharacters

4. Piping into Shell scripts

5. pipes,x11,shell?

6. shells, system, and pipes

7. open()ing a pipe & shell quoting

8. Calling shell scripts or shell commands from Perl

9. Perl Shell instead of C Shell

10. shell script from within a shell script

11. Scheme Shell: Shell Scripting for the 90's

12. Perl qx under NT appears not to shell out to the shell specified by the SHELL env variable


Powered by phpBB® Forum Software