You say it happens on one workstation (but it might happen on others), and it happens only intermittently (it works fine on most iterations, but now and then an iteration fails).

How stable is your solaris network? The error message seems to be saying that when the perl interpreter is trying to load the Net::FTP module, that module includes a "use vars;" statement, and the interpreter fails to find vars.pm. So on that basis, I'd say it has nothing to do with how the C program is creating and running the perl script.

Maybe it just happens occasionally that an iteration fires off when a particular disk volume has been unmounted? or when a particular server has gone down? or when some poor sysadmin is mucking with symlinks that involve some of the perl library paths or causing some similar form of mischief?

Good luck with tracking that down. In the meantime, I would like to reinforce and amplify the suggestion in an earlier reply:

Write the perl script JUST ONCE, and KEEP IT THE SAME. You do not need to rewrite it every time you want to run it. Looking at how the C code is writing the perl code, there seem to be just six parameters that could change from one iteration to the next (ip, user, pw, remotepath, remotefilename, localfilename). It would be simple for a single, unchanging copy of the perl script to read these six values from a parameter file written by the C code.

(You could even put the six params on the command line that the C code executes to run the script, but some people have security concerns about password strings being provided on a command line. I presume you may be writing and deleting the script each time because it contains a user name and password -- but you can write a delete a parameter file just as easily, in fact easier.)

If there is a chance that multiple machines might be running the same C code at the same time, and repeatedly writing their perl scripts to the same directory, then you really do have to work hard on file locking. But if you have just one read-only copy of the perl script (modified to read the six variable values from a given param file), and configure the C code to just write a distinct param file for each iteration, everything becomes a lot simpler and more robust. (Plus you can change/upgrade/fix the behavior of the perl script without having to recompile the C code.)

In other words, the C code just has to do this:

parfile = fopen( uniq_param_name, "w" ); fprintf( parfile, %s %s %s %s %s %s\n", ip, user, pw, remotepath, remotefilename, localfilename ); fclose( parfile ); ... sprintf(line, "perl ftp_script.perl %s", uniq_param_name); do { r = system( line ); ... } ...
Meanwhile, the perl script would be just the same as the C code currently writes it, except that the first executatble statements would be:
my $parfile = shift; open( PAR, $parfile ); $_ = <>; my ( $ip, $user, $passwd, $remotepath, $remotefilename, $localfilename + ) = split; close PAR; unlink $parfile; # why wait for the C code to do this? ...

In reply to Re: Can't locate vars.pm ... sometimes by graff
in thread Can't locate vars.pm ... sometimes by gri6507

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.