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

Perl/Bash Common Variable Question

Thread Next
From:
OTR Comm
Date:
November 21, 1999 08:03
Subject:
Perl/Bash Common Variable Question
Message ID:
38381879.C13111CA@wildapache.net
Hello,

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);
&Initialize_MailScanner_Variables;
&read_config;
print out "Path to uvscan = $uvscan\n" if ($DEBUG gt 4);

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

#!/bin/sh
#
... Shell script

ShellEnd
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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About