05-21-2007
Check if a program runs on unix
Hi guys, I had a question last week where I asked how I check from a website hosted on windows if a process is running on on of our unix servers. Vino and Shell Life kindly replied with a perl script:
if [ $(ps ef | grep '[m]qm') -gt 0 ] ; then
echo "Site is up"
else
echo "Site is down."
# start the server.
fi;
Now to run this script, I would need to telnet into unix and i found the following script:
use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>10,
Errmode=>'die');
$telnet->open(unix);
$telnet->waitfor('/login: $/i');
$telnet->print('admin');
$telnet->waitfor('/password: $/i');
$telnet->print(pass');
$telnet->waitfor('/\# $/i');
$telnet->print('who');
$output = $telnet->waitfor('/\# $/i');
print $output;
So how do I merge these two and run the script from a website?
Thank you in advance
Chris
10 More Discussions You Might Find Interesting
1. HP-UX
my pragram runs with 3 threads, 2 work threads, one main thread. the 2 work threads run with the same mode and the same code. but now, one of the work thread can't work, and it uses the cpu more than 80%, sometimes uses 100% cpu resource. the another work thread work well.
when I viewed the HP... (2 Replies)
Discussion started by: happylife365
2 Replies
2. UNIX for Advanced & Expert Users
I have a ksh script that executes a program with a predetermined timeout in minutes. If the program takes longer then the timeout then it still completes with a return code of 0. :confused:
I would like to determine how long the program ran. Then if it takes longer than the timeout I would... (7 Replies)
Discussion started by: 2dumb
7 Replies
3. Programming
Hi,
How to detect memory leak in C program under unix ?
Thanks (6 Replies)
Discussion started by: useless79
6 Replies
4. Linux
In unix how we can test or check race condition in any c program by using multi thread programming (1 Reply)
Discussion started by: afroze
1 Replies
5. UNIX for Dummies Questions & Answers
In unix how we can test or check race condition in any c program by using multi thread programming (1 Reply)
Discussion started by: afroze
1 Replies
6. Programming
In unix how we can test or check race condition in any c program by using multi thread programming (5 Replies)
Discussion started by: afroze
5 Replies
7. Programming
In unix how we can test or check race condition in any c program by using multi thread programming (1 Reply)
Discussion started by: afroze
1 Replies
8. Shell Programming and Scripting
I have a crontab as below:
PATH=/usr/local/sbin:/bin/:..... etc etc
0 8 * * * /home/user/jobs/poll.sh 2>/dev/null 1>/dev/null
Now the script poll.sh is called at correct time and executes.
This is how poll.sh looks like
#!/bin/bash... (2 Replies)
Discussion started by: chakrapani
2 Replies
9. Homework & Coursework Questions
I need help program in C... :create a program that runs two processes linked oven (1 Reply)
Discussion started by: gizmo16
1 Replies
10. UNIX for Beginners Questions & Answers
Hey guys, I was wondering. When I enter a command in the terminal -wcl for a word count, where is that program located in the kernel? (7 Replies)
Discussion started by: Circuits
7 Replies
LEARN ABOUT SUNOS
telnetrc
telnetrc(4) File Formats telnetrc(4)
NAME
telnetrc - file for telnet default options
DESCRIPTION
The .telnetrc file contains commands that are executed when a connection is established on a per-host basis. Each line in the file con-
tains a host name, one or more spaces or tabs, and a telnet(1) command. The host name, DEFAULT, matches all hosts. Lines beginning with the
pound sign (#) are interpreted as comments and therefore ignored. telnet(1) commands are case-insensitive to the contents of the .telnetrc
file.
The .telnetrc file is retrieved from each user's HOME directory.
EXAMPLES
Example 1: A sample file.
In the following example, a .telnetrc file executes the telnet(1) command, toggle:
weirdhost toggle crmod
# Always export $PRINTER
DEFAULT environ export PRINTER
The lines in this file indicate that the toggle argument crmod, whose default value is "off" (or FALSE), should be enabled when connecting
to the system weirdhost. In addition, the value of the environment variable PRINTER should be exported to all systems. In this case, the
DEFAULT keyword is used in place of the host name.
FILES
$HOME/.telnetrc
SEE ALSO
telnet(1), in.telnetd(1M), environ(5)
SunOS 5.10 9 Jan 1998 telnetrc(4)