"Also there's no $text variable in my script nor am I doing any substitution. Even if I embed the username and password in the script I still get the error."

The error tells you exactly where this is coming from:

G:\>perl cdr_vnxe\cedar_rapids_vnxe_v2.pl Use of uninitialized value $text in substitution (s///) at G:/Strawber +ry/perl/vendor/lib/Win32/ShellQuote.pm line 85.

"What baffles me is the script works fine if I run it from the directory where its in. No errors whatsoever. Just when I run it with the path, the error comes up. "

You have:

my $array_creds = Config::Tiny->new(); $array_creds = Config::Tiny->read('vnxe_config.conf');

Consider the following example:

#!/usr/bin/perl use strict; use warnings; use Config::Tiny; my $Config = Config::Tiny->new; $Config = Config::Tiny->read( 'file.conf' ); print "$Config->{_}{var1}\n";

When run from the directory containing your config file:

marto@Marto-Desktop:~/code$ ./cf.pl derp

When run from the parent directory:

marto@Marto-Desktop:~$ ./code/cf.pl Use of uninitialized value in concatenation (.) or string at ./code/cf +.pl line 8.

As you see, the code can't find the config file.

#!/usr/bin/perl use strict; use warnings; use File::Basename; my $dirname = dirname(__FILE__); use Config::Tiny; my $Config = Config::Tiny->new; $Config = Config::Tiny->read( "$dirname/file.conf" ); print "$Config->{_}{var1}\n";

Runs fine:

marto@Marto-Desktop:~$ ./code/cf.pl derp

Update: IPC::Run3 needs Win32::ShellQuote because you are on Windows. https://metacpan.org/source/RJBS/IPC-Run3-0.048/Makefile.PL#L13.


In reply to Re^3: Perl script runs fine if exec'd from the directory, but gives error if run outside the directory. by marto
in thread Perl script runs fine if exec'd from the directory, but gives error if run outside the directory. by pritesh_ugrankar

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.