Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Passing user input to a shell command

by james734 (Initiate)
on May 17, 2007 at 22:06 UTC ( [id://616121]=note: print w/replies, xml ) Need Help??


in reply to Re: Passing user input to a shell command
in thread Passing user input to a shell command

I know that the file $file does not exist, I open it to insure that user is typing the file exists. The question should have been how do I tell the shell line that $file = <STDIN> is the value that is entered by the user and to put it into the shell line ie User enters test.txt So $file is now = test.txt the shell command shout be perl /Users/james/perlstuff/macc/macc1 test.txt. James
  • Comment on Re^2: Passing user input to a shell command

Replies are listed 'Best First'.
Re^3: Passing user input to a shell command
by jdporter (Paladin) on May 17, 2007 at 22:18 UTC
    I open it to insure that user is typing the file exists

    Opening it is not the best way to do that. There are the file test operators, such as -f:

    -f $file or die "You specified a non-existent file.\n";

    Even if you do open it for this purpose, you should definitely close it right away, before letting another process have it.

    A word spoken in Mind will reach its own level, in the objective world, by its own weight
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://616121]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-16 08:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found