LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-02-2003, 05:13 AM   #1
pk21
Member
 
Registered: Jun 2002
Location: Netherlands - Amsterdam
Distribution: RedHat 9
Posts: 549

Rep: Reputation: 30
Threads in bash?


I want to test my sshd locally, with the following lines:

#/bin/bash
Connection=$(telnet localhost 22|grep OpenSSH)
ps ax|grep telnet|kill -9 $(awk '{ print $1 }')

But ofcourse only the first line gets executed and it never gets to the second line. So my question, is it possible to use threads in bash? Or is there another solution for this?
 
Old 06-02-2003, 05:56 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Cuz you didn't background the job sshd will wait 'til login timout before returning.
In any case I think it would be better to separate the action from the output (configurability, timeout, unknown input), using a little "expect" script could help, or if this is a permanent test, have a look at "Monit". Btw, for the ps thingie you can use "kill -9 $(pgrep telnet)" provided you can only see your users PID's or select by UID if you're running more telnet sessions, and don't forget you can also use $? (or ${#Connection}) for actions based on the output of telnet if the var doesn't hold stuff...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java threads listed using kill -3 does not contain all threads found using ps -auxww coneheed Programming 2 11-14-2005 08:57 AM
threads JurajPsycho Programming 5 02-22-2005 08:58 AM
threads JurajPsycho Debian 1 02-20-2005 02:36 PM
Java Threads vs Native Threads rjmendez Programming 0 08-16-2004 05:58 AM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration