Telnet and get process count


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Telnet and get process count
# 1  
Old 09-21-2015
Telnet and get process count

Hi guys,

I'm writing a script on a Solaris 10 server (server A) that needs to telnet 2 servers (server B & server C) and get a certain process count from these 2 servers.

Then on server A, I check if both counts are greater than 17, I do a sendmail to concerned people.

For the telnet part, this is what I'm trying to do and getting stuck:
Code:
{
sleep 5
echo root
sleep 3
echo password
sleep 3
##echo ls
uname -a
sleep 5
echo exit
} | telnet 192.168.20.71

Instead of the 'echo ls' above, I wanted to do something like
Code:
ps -ef|grep dw.sap|wc -l

and get the value back in server A

Please tell me how I can do the process count and get it back to server. Or, do tell me if there's some other way...


regards
# 2  
Old 09-21-2015
Why are you using telnet instead of a remote shell ( rsh etc...) or ssh ?
# 3  
Old 09-21-2015
e.g. as here remote shells are blocked by routers for security:
Code:
n12:/home/vbe $ uname;ssh barge "uname && ps -ef|grep vbe|wc -l"
AIX
Password: 
SunOS
       4

as I have not used publick keys for no passwd setting on this remote box ( as I dont normally connect to it but cant think of another solaris at the moment...) It has asked my passwd... but this gives you the idea...
This User Gave Thanks to vbe For This Post:
# 4  
Old 09-21-2015
Hi Vbe,

Thanks lots for the help.

Indeed ssh seems to work fine.
Now, in the script how will I provide the root password when I do the ssh?

Secondly, how will I capture the value of the count - how can I store it to some variable?

regards.
# 5  
Old 09-21-2015
You best set ssh up for public key authentication, so you don't have to supply any password.
You can capture the output by using "command substitution" like A=$(ssh ...).

Last edited by RudiC; 09-21-2015 at 08:46 AM.. Reason: changed authorisation for authentication
This User Gave Thanks to RudiC For This Post:
# 6  
Old 09-21-2015
Hi RudiC,

Thanks for the info. I had read about the public key authentication but I won't be able to do it as of now.
Is there some other way?

regards.
# 7  
Old 09-23-2015
Hi all,

I was able to do it using rsh.

Thanks all for the help.

regards.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Process a file for line count using for loop in awk

Hi, I have a file with contents So what I have to do is In short, break the file after every 6 lines and then truncate new line to tab for these 6 lines. I am not able to execute the for loop in awk properly. The idea is something like this: less file| awk '{for .... {if ((nr>=1)... (7 Replies)
Discussion started by: rossi
7 Replies

2. AIX

Check process count

Hi, We have scheduled few jobs/scripts in cron and it runs on daily basis at a specified time. We have a cron jobs has various parameters for main scripts like /home/test/mainscript.ksh main_param when the above jobs triggers, mainscript.ksh has below code and it refers ... (3 Replies)
Discussion started by: Selva_2507
3 Replies

3. Shell Programming and Scripting

Process count problem in script

Hi, I am trying to make a script which should execute if the same is not getting executed already. To implement this check, I wrote a fragment of code as below $ cat abc.sh #!/bin/bash check=0 #grepping "sh -x abc.sh" because if i check only for "abc.sh" and the file is open in say... (12 Replies)
Discussion started by: sam05121988
12 Replies

4. Shell Programming and Scripting

Using backspace in echo to show process count

i have something like this tablesName="abc def hij akn ... etc etc" count=0 for i in $tablesName do echo -en "\b\b\b\b\b\b\b\b\b\b\b\b\bTableCount: $count" count=`expr $count + 1` done the above is just a description wha i need is when the loop executes the... (1 Reply)
Discussion started by: vivek d r
1 Replies

5. Shell Programming and Scripting

Suppressing output of a spawned telnet process

Hi, I'm trying to spawn a telnet process and trying to do some actions in the remote host using expect script. I would like to know how to suppress all the output in order the user using the script should not be able to see any actions done on the remote host. I tried using the "log_user 0"... (8 Replies)
Discussion started by: arun_maffy
8 Replies

6. UNIX for Dummies Questions & Answers

Thread count for a process id

Hi, I want to know a command/program to get thread count for a process id in unix box. Please help me in this regard. (1 Reply)
Discussion started by: manaac
1 Replies

7. Shell Programming and Scripting

Command to find out "count" of running process ?

Hello Experts, Can any one help me out to find the command to get "count" of number of processes running in system. Basically i want to write one crone job to kill some process which making my system hanged. so have to do following things. 1) Find out the number of processes is running.... (4 Replies)
Discussion started by: MITESH KOTHARI
4 Replies

8. HP-UX

how to see the threads count of a process in hp unix?

hi,all: how to see the threads count of a process in hp unix? thanks (2 Replies)
Discussion started by: bugbugbug
2 Replies

9. Programming

Count Number Of Threads in a Process

I am trying to find out that how many number of threads are currently running or in any other state which is created by POSIX standard in a process. First I have defined a variable called proc_var of type proc defined in sys/proc.h.Next I open up the dir /proc and per directory wise I do an ioctl... (7 Replies)
Discussion started by: S.P.Prasad
7 Replies

10. UNIX for Dummies Questions & Answers

exit from telnet kills orbix process

Hi, I'm using a bourne shell to kick off a 3rd Pty app. This app uses Orbix. When I exit from the telnet session which started the app or hit CTRL-C at the command line, the orbix process dies, yet all other process remain. I've tried starting the app as a background process, but it still... (1 Reply)
Discussion started by: edgarm
1 Replies
Login or Register to Ask a Question