Desperately seeking wisdom...

I've been banging my head against a simple problem all day. I have a simple cgi script that takes three parameters from a form, creates a file and then is supposed to run a seperate script (indexer.pl, located in the same directory) which updates an index file with some elements of the new file. All works well until it's time for the indexer script to run.

Since I'm not interested in capturing the output of indexer.pl, I first tried:

my $status = system("perl /path/to/indexer.pl"); error("Index update failed") unless ($status == 0);

This resulted in the error being called. Running the script from the command line it looked like indexer.pl thought it was located in a different directory. I put a chdir statement at the top of indexer.pl but this did not help.

On the chance that I was using the system call incorrectly, I also tried back ticks despite the inefficiency of ignoring their return values:

`perl /path/to/indexer.pl`;

Again, no luck. The results where the same whether I use relative or full paths. From what read in the Perl Cookbook and Programming Perl I think I'm using the functions correctly. I even wrote a three line script that called another which then printed its current directory to a file. Those two files worked as expected; they recognized they were in the same directory. Can anyone point me in the right direction?

Thanks, sz

In reply to Problem calling one script from another by sz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.