I am trying hard to run the below line with sudo, I am not able to handle the password prompt in my script. You are perfectly correct about your observation about permission problem. I have two option for that, either to use ssh command in a shell file and then call it like below:
`/bin/sh /tmp/rockpingping.sh $nodeName > /tmp/result.txt`;
The above solution is working, but it is not a good way of doing things.
And the second option is using sudo. I am not succeeding sudo option where it password prompt is popping up.
$flag = system("sudo /bin/sh /tmp/sshping.sh > /tmp/result.txt" );
+ ## '>' is the redirect operator and test.sh is the shell script
If ($flag == 0 )
{
// The success result will be stored at result.txt
// need to open this file and then use it
}
else
{
// failure case
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.