Hi Gurus,
I have small issue...
I used to pass the passwd for sudo commands like below,
gzcat ~/passwd.gz | sudo su - <villin> >> eof
------
-----
------
eof
And it was able to login into "villin" sudo account successfully. But now, I'm using the same in another script for the same sudo account login... It's not working now and I'm getting below error,
My script:
#!/bin/bash
CMD="sudo su - villin"
gzcat ~/passwd.gz | ${CMD} << eof1
sh New_report_dev.sh
eof1
Error:
Do I need to set any variable here to achieve this?
Can anyone please advice?
Regards,
VRN
---------- Post updated at 09:26 PM ---------- Previous update was at 08:03 PM ----------
Hello frnds,
I found the issue, but i need some more help...
Actually it's working for sometimes, nit working for sometimes...
But after logged into sudo account, the default shell is 'csh'. So after logged into this account, I'm trying to set some env variables. The syntax of setting variables and calling them inside csh is wrong...
#!/bin/bash
CMD="/usr/bin/sudo /bin/su - villin"
gzcat ~/code.gz | ${CMD} << eof1
echo "Logged into villin successfully"
#Once logged into this account, the default shell is 'csh' here.
set PATH1 = ~/pd/perl/prod/bin/perl
set PATH2 = ~/logs/temp
$argv[$PATH2] $argv[$PATH3]New_report_dev.pl
exit
eof1
It's unable to read those variables and the Perl script is not executing here...
Can anyone please have a look at the below my code and suggest on this?
Regards,
VRN