Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Comment on

by gods
on Feb 11, 2000 at 00:06 UTC ( #3333=superdoc: print w/replies, xml ) Need Help??

I need to export variable as another user and need to confirm whether the variable is exported or not How Do I acheive that. I am trying to append the export command to a file and run the file as script but is not working

my $pig_file = system("ls /home/mrdemo1/pig.jar"); my $pig_directory = system("ls /home/mrdemo1/pigtmp"); open (PH,">>/home/mrdemo1/pig_profile_tmp") or die $!; my $pig_directory_path = `echo \'export PIGDIR=/home/mrdemo1\' >> /hom +e/mrdemo1/pig_profile_tmp`; my $hadoop_site_path = `echo \'export HADOOPSITEPATH=/etc/hadoop/conf\ +' >> /home/mrdemo1/pig_profile_tmp`; my $bash_profile_run = system(". /home/mrdemo1/pig_profile_tmp); my $pig_directory_path_exist = `runuser -l mrdemo1 -c 'echo \$PIGDIR'` +; my $hadoop_site_path_exist = `runuser -l mrdemo1 -c 'echo \$HADOOPSITE +PATH'`; chomp($pig_directory_path_exist); chomp($hadoop_site_path_exist); print " PATH IS $pig_directory_path_exist and $hadoop_site_path_exist" +; #if ( "$pig_directory_path_exist" ne "/home/mrdemo1" || "$hadoop_site_ +path_exist" ne "/etc/hadoop/conf" ) #{ # print " PIGDIR NOT SET. SET PIGDIR TO /home/mrdemo1 using comm +and ..................runuser -l mrdemo1 -c 'export PIGDIR=/home/mrde +mo1' OR SET HADOOPSITEPATH TO /etc/hadoop/conf using command runuser +-l mrdemo1 -c 'export HADOOPSITEPATH=/etc/hadoop/conf' OR SET BOTH \n +\n"; # print " Exiting...................\n\n"; #} output [root@r01mgt ~]# perl testscript.pl Bareword found where operator expected at testscript.pl line 12, near +"print " PATH" (Might be a runaway multi-line "" string starting on line 7) (Do you need to predeclare print?) String found where operator expected at testscript.pl line 13, near "# +if ( "" (Might be a runaway multi-line "" string starting on line 12) (Missing semicolon on previous line?) Scalar found where operator expected at testscript.pl line 13, near "# +if ( "$pig_directory_path_exist" (Missing operator before $pig_directory_path_exist?) String found where operator expected at testscript.pl line 13, near "$ +pig_directory_path_exist" ne "" (Missing operator before " ne "?) String found where operator expected at testscript.pl line 13, near "m +rdemo1" || "" Scalar found where operator expected at testscript.pl line 13, near "" + || "$hadoop_site_path_exist" (Missing operator before $hadoop_site_path_exist?) String found where operator expected at testscript.pl line 13, near "$ +hadoop_site_path_exist" ne "" (Missing operator before " ne "?) String found where operator expected at testscript.pl line 15, near "# + print "" (Might be a runaway multi-line "" string starting on line 13) (Missing semicolon on previous line?) Bareword found where operator expected at testscript.pl line 15, near +"# print " PIGDIR" (Missing operator before PIGDIR?) Bareword found where operator expected at testscript.pl line 15, near +"'export PIGDIR=/home/mrdemo1' OR" (Missing operator before OR?) Bareword found where operator expected at testscript.pl line 15, near +"'export HADOOPSITEPATH=/etc/hadoop/conf' OR" (Missing operator before OR?) Backslash found where operator expected at testscript.pl line 15, near + "BOTH \" (Do you need to predeclare BOTH?) Backslash found where operator expected at testscript.pl line 15, near + "n\" String found where operator expected at testscript.pl line 16, near "# + print "" (Might be a runaway multi-line "" string starting on line 15) (Missing semicolon on previous line?) Bareword found where operator expected at testscript.pl line 16, near +"# print " Exiting" ...........

In reply to I need to export variable as another user by rahulruns

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (3)
    As of 2016-10-01 22:37 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      How many different varieties (color, size, etc) of socks do you have in your sock drawer?






      Results (9 votes). Check out past polls.