Need some help, Have been looking for any solutions and more than likely is something simple but i am too new to this stuff. Here is my problem I need to execute a series of commands and display the output on a page. Some limitations, - the user i using is able to ssh to servers without password. (user1) - the web server executing the script runs under root So i need to sudo the ssh user1@server echo "someotherserver" I believe my problem is with the syntax from the many concatenated commands Here is the section that is killing. (did i mention i am way new to this, On 2 days as of 12/22/14) Tried with No luck
my $dwfssh = "/usr/bin/sudo -u netcool /usr/bin/ssh -t user1\@serverna +me"; #Ping Route Section print "<p class=\"systemMsg\">Pinging $msg1 from Orlando </p>"; #open(PINGORF,"$dfwssh '/bin/ping -c 5 -q ".$test1."'|"); open(PINGORF,"/bin/ping -c 3 ".$test1."|"); $old_fh = select(STDOUT); $| = 1; select($old_fh); print "<PRE><p class=\"results\">"; while(<PINGORF>) { print; } print "</p></PRE>"; print "<p class=\"systemMsg\">Pinging $msg1 from Dallas </p>"; #open(PINGDWF,"$dfwssh '/bin/ping -c 5 -q ".$test1."'|"); $cmd1 = "/usr/bin/sudo -u 'user1 echo "Darn thing wont workr"'"; open(PINGDWF,"$cmd1"); #open(PING,"/bin/ping -c 10 ".$test1."|"); $old_fh = select(STDOUT); $| = 1; select($old_fh); print "<PRE><p class=\"results\">"; while(<PINGDWF>) { print; } print "</PRE></p>";
btw: i also tried the full command instead the variables in the Open thing I am able to run the echo and other commands in the script from the command line without problems but i place them back here i get No output..
In reply to Perl CGI SUDO -> SSH -> Command by maguilu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |