perl issuing os command with defined variables
Posted
by
Vinnie Biros
on Stack Overflow
See other posts from Stack Overflow
or by Vinnie Biros
Published on 2013-07-02T16:49:44Z
Indexed on
2013/07/02
17:05 UTC
Read the original article
Hit count: 439
I am adding functionality into my scripts so that they can use kerberos authentication to run automatically and use secure protocols when executing. I have my functionality working for shell scripts that do exactly what i want, however i am having issues porting it to perl to work within my perl scripts as i am new to perl. Here is my working shell code and trying to get the same functionality in perl:
#!/bin/sh
ticketFileName=`basename $0-$$` #set filename variable to name of script plus the PID
krb5CacheLocation=/tmp/$ticketFileName #set ticket cache location to /tmp + script name
/usr/share/centrifydc/kerberos/bin/kinit -c $krb5CacheLocation -kt /root/.ssh/someaccount.keytab someaccount #get TGT and specifiy ticket cache location on kinit
export KRB5CCNAME=$krb5CacheLocation #set the KRB5CCNAME variable to tell ssh where to look
What i have attempted in perl:
#!/usr/bin/perl
my $ticketFileName = `basename $0-$$`;
my $krb5CacheLocation = '/tmp/'.$ticketFileName;
`export KRB5CCNAME=$krb5CacheLocation`;
`/usr/share/centrifydc/kerberos/bin/kinit -c $krb5CacheLocation -kt /root/.ssh/unixmap0000.keytab unixmap0000`;
Seems it is not liking the passed variable that i am referencing in the OS command. Anyone have any ideas or suggestions?
© Stack Overflow or respective owner