Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

im a new perl programmer and have been asked to do write a program which will prompt the user for a single external unix command for a child process which then executes it. i have to make sure that when it can not find a command the process is terminated. im having the problem that the process continues to spawn loads of children. thanks the not very bright one.

Replies are listed 'Best First'.
Re: simple perl
by suaveant (Parson) on Jun 18, 2001 at 17:45 UTC
    Look at exec and system, these are probably the functions you would use, they both have ways of letting you know a file was not there to be executed, or at least, that the command failed...

    if they are always going to give you full path to a command you can use -f filename and -x filename to make sure it is a file and that the user can execute it...

    this sounds a bit like a homework assignment...

                    - Ant

Re: simple perl
by scottstef (Curate) on Jun 18, 2001 at 17:47 UTC
    I would suggest posting a snippet of the code you have written adn someone will probably be able to help with this. (When posting your code, make sure you use the code tags)

    "The social dynamics of the net are a direct consequence of the fact that nobody has yet developed a Remote Strangulation Protocol." -- Larry Wall

simple(?) perl
by Chady (Priest) on Jun 18, 2001 at 18:27 UTC

    ew ew ew..

    who said anything about simple??

    • are you sure your user has always good intentions??
    • does your user enters the command and you just pass it along? or do you check what he is trying to access and run?
    • are you using special keys for special command? or can the user run the command directly?

    check for all that, and then, see if it's simple..


    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

    Chady | http://chady.net/