Click here to get back home

Shell::Jobs - request for comments

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Shell::Jobs - request for comments Jaap Karssenberg 02-12-2005
Posted by Jaap Karssenberg on February 12, 2005, 2:33 pm
Please log in for more thread options
Lectori Salutem

In an effort to make the code developed for the Zoidberg shell[1] more
generally available for CPAN I am considering creating a new module by
forking off most of the shell-command-parsing and job-control code from
zoidberg. On the one hand this will force me to have a strict api
between the parser and the rest of the framework, allowing for a better
test suite, on the other hand it will make general job control and
shell-like-parsing available for perl scripts and as a base for other
perl shells.

I ask for suggestions and comments for
A) a name for this module and
B) how the api should work
The current working name is Shell::Jobs.
Below follows a synopsis of the api I'm thinking of:

use Shell::Jobs qw/job @JOBS shell $JOBS/;

# Run a shell command in the background
# job() creates a new background job
my $job = job('cp ./big.tar.gz /data/backup &');
print "Copying ...";
while ($job->running) { print '.', sleep 3 }
print $@ ? "nFailed: $@" : "n";

# Fork a bunch of processes
# running code in a background job effectively forks the
# current process
for (1..5) { job(&run_child) }
while (@JOBS) {
print "$$_ has endedn" unless $_->running for @JOBS;
sleep 3;
}

# The quick n dirty command shell
# examples on how to hook builtin commands etc. will follow once the
# module really exists :)
# shell() creates a new job, can be foreground or background
# $JOBS is an object that calls one method for all objects in @JOBS
while (<STDIN>) {
shell($_);
print STDERR $@ if $@;
$JOBS->report; # check for background jobs that have ended
}
$JOBS->kill('HUP'); # cleanup remaining background jobs

Because we reuse code from zoidberg the parser will do (most) shell
parsing without depending on bash or sh, this includes things like
pipelines, redirections and command substitution.

I am aware of the existence of IPC::Run on CPAN, and although some
features will overlap the functionality won't be the same.

Greetings,
        Jaap Karssenberg



[1] Zoidberg (a.k.a. zoid) :
A modular Perl shell written, configured, and operated entirely in Perl.
It aspires to be a fully operational login shell with all the features
one normally expects. But it also gives direct access to Perl objects
and data structures from the command line, and allows you to run Perl
code within the scope of your command line.
http://zoidberg.sf.net


Similar ThreadsPosted
CGI::UploadEasy - request for comments March 31, 2005, 10:16 pm
Patent::Retrieve Request for Comments February 12, 2005, 8:52 pm
How to to many things in a shell.. April 21, 2005, 2:18 am
CPAN shell says "Out of memory!" December 30, 2005, 5:15 pm
Namespace and comments on usefulness sought October 26, 2004, 9:52 am
Installing WWW::Mechanize from CPAN shell May 24, 2007, 4:56 pm
My Bundle::Modules not installing with the CPANPLUS shell May 19, 2006, 2:55 pm
Required Perl Developer w/ UNIX. SQL and Shell Scripting. March 24, 2006, 6:41 pm
Stopping the cpan shell from fetching the modules list August 10, 2006, 3:45 am
Tips on module selection for shell and/or commandline 'subcommand' behavior January 16, 2007, 5:19 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap