Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

system command

Status
Not open for further replies.

webscripter

Programmer
Jul 29, 2002
266
US
Does anyone know how to use the system command to execute the indexer.pl file for perlfect search? I don't have a shell account. I want to pass the password parameter to the script with something like this:

my $rv = system("cd $instdir;perl indexer.pl password=zipzip");

Does this work?


Thanks
Tricia
yorkeylady@earthlink.net
 
surrond the command in ticks like so:

`c:\\perl indexer.pl password=zipzip`;

 
Tricia,

That should work actually -- the return value you get is a bit of a pain because it doesn't work in the same way as most Perl functions.

Most Perl functions return 0 for failure and something else for success.

The system() function returns values like the UNIX shells, 0 for success and an error number for failure.

Stiddy's example will work ok with one addition (sorry to butt in Stiddy)

The backticks (``) return the output of the command, so running this:

$var = `ls`;

will fill $var with the output you would normally see from ls

Mike
________________________________________________________________

"Experience is the comb that Nature gives us, after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
Thanks for that piece of info. The script does test for a boolean value. If I had a shell account I could see that the indexer is working properly. As it is via http it only returns one page and sometimes none, when I know the info exists.

Is this correct?

$var = system(`cd $instdir; perl indexer.pl password=zipzip`;) Thanks
Tricia
yorkeylady@earthlink.net
 
Don't use the backticks with the system call. Use one or the other. i.e.

Code:
$var = system("cd $instdir; perl indexer.pl password=zipzip");
or
Code:
$var = `cd "$instdir"; perl indexer.pl password=zipzip`;

the "" are needed because perl won't interpolate unless there are quotes. --Derek

"Fear not the storm for this is where we grow strong."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top