develooper Front page | perl.perl5.porters | Postings from November 1999

Perl/Bash Common Variable Question

Thread Next
OTR Comm
November 21, 1999 08:03
Perl/Bash Common Variable Question
Message ID:

I realize that this is not 'porting' question, but nothing vertured,
nothing gained, huh?

I have perl scripts that have embedded shell scripts.  For example, in
one I call the shell script with a statement like so:

#!/usr/bin/perl -w

... Commented header stuff (who, what, when, why, where)

require "initialize.sub";
$DEBUG = 5;
open (out,"+< /usr/mailscanner/debug.log") if ($DEBUG gt 4);
print out "Path to uvscan = $uvscan\n" if ($DEBUG gt 4);

system '/bin/sh', '-c', <<'ShellEnd', $0, @ARGV;

... Shell script

print out "Path to AvpLinux = $AvpLinux\n" if ($DEBUG gt 4);
close(out) if ($DEBUG gt 4);
exit 0

The variables uvscan and AvpLinux are read from a configuration file
(mailscanner.config) by the &read_config statement.  These variables are
available in my perl script before the system statement and after; i.e.,
both print out statements produce the correct data.

However, the variables are not available in the shell script.  Is there
a way to have these variables available in my shell script also?

I have some large shell scripts and I am too lazy to translate the logic
to perl (some of it I don't even know how to) and want to just wrap them
in a 'system' function and embed the wrapped logic in perl scripts that
expand the functionality of the original scripts.

Another question!  Before I can have access to the routines in
'initialize.sub', I have to copy 'initialize.sub' to
/usr/lib/perl5/5.00503/i386-linux.  I believe that this is because I do
not have something setup correctly in my perl installation, but I do not
know what.  Any ideas?  I want to keep 'initialize.sub' in the same
directory as the perl script

Thanks in advance,
Murrah Boswell

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About