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

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, details, 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, summary, 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.