in reply to Passing $EUID to cshell script through system command in Perl

In Perl, declaring a variable does not create an environment variable. Think of it being a bit like 'set' in C-shell. Instead, environment variables are exposed as a hash called %ENV.

To pass an environment variable you need something like this:
$ENV{EUID} = getpwnam(jjack);
However it appears you actually want to run a program under a different user name, in which case you probably need to call something like su(1).

Update: After more consideration, I think you are mis-understanding the EUID variable. This variable is set by bash, and it is readonly (in bash only). It is not normally exported, so will not be in the environment. EUID is not used by the C-shell so far as I can tell, and it neither reads nor writes to it.

Replies are listed 'Best First'.
Re^2: Passing $EUID to cshell script through system command in Perl
by Anonymous Monk on Jul 19, 2011 at 19:23 UTC

    Thank you, after reading your $EID not available comment it made me think in terms of bash and im now executing the script as sudo and it seems to work.

    system("sudo -u $var1 /net/watusi/usr1/scripts/submitjobs.sh");

    here $var1 is jjack, file /net/watusi/usr1/scripts/submitjobs.sh below

    #!/bin/sh -p . /net/watusi/usr1/lsf8.0/conf/profile.lsf bsub -q lxpt64_2cpu -o /dev/null -e /dev/null sleep 10

    All these jobs are now being submitted into LSF with the Effective user id I wanted