perl... how to tell if a piped command is still running?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl... how to tell if a piped command is still running?
# 1  
Old 08-17-2005
perl... how to tell if a piped command is still running?

I'm using the fabulous perl. I need a way to tell when a piped call to "open" has completed. Can I do this with a command like <ShellPipe> ??


Reason behind this:

I'm trying to write a backup script in perl! This script will download a certain file from my web server, to my computer.

Now, this perl script calls wget something like this:

open( ShellPipe, "wget http://url.com" );

Is there some way to get wget to delete the file if the file download got interupted? Otherwise I'll have a partially downloaded backup!

My script is smart enough, that it will try again if the file doesn't exist, you see. But what if the download got interupted? Then a file will exist, and I'll have a bad backup.

I know it's unlikely to get interupted, but I like to take care and be very sure of these things Smilie

Also, my webserver does not tell me the size of the file to be downloaded. It tells you when there is no more data, though.

So for this reason, I just need to tell when the pipe has been completed.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing an argument using alias to piped command

Hi. I'm trying to do a "simple" thing. grep -rls grepped_exp path | xgs where xgs is an alias to something like: xargs gvim -o -c ":g/grepped_exp" now the problem is that I want to pass the "grepped_exp" to the piped alias. I was able to do something like what I want without the... (4 Replies)
Discussion started by: hagaysp
4 Replies

2. Programming

Running java script from piped output

to run most other scripts through a pipe, something similar to the following is usually enough: cat script.sh | sh cat perl.pl | perl -- "<arguments" However, for javascript command line scripts, i cant seem to get this to work. Any ideas? cat hull.js #!/usr/bin/js ... (3 Replies)
Discussion started by: SkySmart
3 Replies

3. Shell Programming and Scripting

Can't Output Piped Perl In-line command to a File

Hello, I'm pretty stumped, and I don't know why I am not able to redirect the output to the 'graphme' file with the command below in Fedora 18. tcpdump -l -n -t "tcp == 18" | perl -ane '($s,$j)=split(/,/,$F,2); print "$s\n";' > graphme In case you're wondering, I was following the example... (2 Replies)
Discussion started by: ConcealedKnight
2 Replies

4. Shell Programming and Scripting

Perl: How to check if there is something being piped in

Hi, I am somewhat new to Perl and currently checking it out. I have a problem testing, if there is nothing being piped in to that script. I am reading input from STDIN this way: while( defined($line = <STDIN>) ) { chomp($line); if( $line =~ m/($ARGV)/g ) { ... (7 Replies)
Discussion started by: zaxxon
7 Replies

5. Shell Programming and Scripting

Trouble executing piped shell commands in perl code

I am trying to execute a piped combination of shell commands inside a perl program. However, it is not working as desired. This is my program, i am trying to print only filenames from the output of ls -l $ cat list_test #!/usr/bin/perl -w use strict; my $count=0; my @list=`ls -l|awk... (4 Replies)
Discussion started by: sam05121988
4 Replies

6. Shell Programming and Scripting

running shell command in Perl script

Does not work. #!/usr/bin/perl $etcdir = 'ls -l /etc'; print $etcdir; #END ------------result-------- #perl -w abc123.pl ls -l /etc # This method works. #!/usr/bin/perl $etcdir = system("ls -l /etc"); print $etcdir; #END (2 Replies)
Discussion started by: dplinux
2 Replies

7. Shell Programming and Scripting

How to execute piped command using exec or system

Hi All, I want to execute a piped command like 'ls /opt | grep xml' using array as parameters list. How can I do that? (2 Replies)
Discussion started by: bharadiaam
2 Replies

8. Shell Programming and Scripting

perl for running ps -ef command

I have following script $cmd="ps -ef |"; open(PSINFO, $cmd) || die "Unable to get ps -ef information from System"; while running script with above lines, it is showing following err ps: illegal option -- f usage: ps (1 Reply)
Discussion started by: aju_kup
1 Replies

9. Shell Programming and Scripting

Return value of piped command?

grep $SEARCH_STRING /etc/passwd | cut -d":" -f 1,5 I need to check the $? value of grep in the above. If I place a test for $? after the above piped command, it returns success status of grep piped to cut. How can I get the success status of grep alone? (5 Replies)
Discussion started by: krishmaths
5 Replies
Login or Register to Ask a Question
OPEN(1) 							     Linux 1.x								   OPEN(1)

NAME
open - start a program on a new virtual terminal (VT). SYNOPSIS
open [-c vtnumber] [-s] [-u] [-l] [-v] [--] command command_options DESCRIPTION
open will find the first available VT, and run on it the given command with the given command options, standard input, output and error are directed to that terminal. The current search path ($PATH) is used to find the requested command. If no command is specified then the envi- ronment variable $SHELL is used. OPTIONS -c vtnumber Use the given VT number and not the first available. Note you must have write access to the supplied VT for this to work. -s Switch to the new VT when starting the command. The VT of the new command will be made the new current VT. -u Figure out the owner of the current VT, and run login as that user. Suitable to be called by init. Shouldn't be used with -c or -l. -l Make the command a login shell. A - is prepended to the name of the command to be executed. -v Be a bit more verbose. -w wait for command to complete. If -w and -s are used together then open will switch back to the controlling terminal when the command completes. -- end of options to open. NOTE
If open is compiled with a POSIX (Gnu) getopt() and you wish to set options to the command to be run, then you must supply the end of options -- flag before the command. EXAMPLES
open can be used to start a shell on the next free VT, by using the command: open bash To start the shell as a login shell, use: open -l bash To get a long listing you must supply the -- separator: open -- ls -l SEE ALSO
login(1), doshell(8), switchto(1). AUTHOR
Jon Tombs <jon@gtex02.us.es or jon@robots.ox.ac.uk> -w idea from "sam". 19 Jul 1996 V1.4 OPEN(1)