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 10-27-2005, 10:29 AM   #1
jaimese
LQ Newbie
 
Registered: Oct 2005
Posts: 11

Rep: Reputation: 0
Problems with multiple procedures


Hi!

I´ve move this post from the newbie section becuase I think this is a best place to place it in.

I´m trying to write an script that makes telnet connections with network devices in order to monitorize them. It connects, get some parameters, write them to a temp file and close the connection. The code for the connection y more or less this:

(

code to be done inside the device

)telnet xx.xx.xx.xx >> data.txt

This estructure works perfectly if the console responses but if not, the scripts hangs, until the timeout of the console is over. In this moment, the scripts finishes.

My problem is I want to make any kind of control estructure to avoid this situation. I have tried to control the process, but it seems the main script stops until the child completes the connection so I can't do anything.

I really need help and I will thank u a lot any kind of information, advice or idea.

Thanks,

Jaime.
 
Old 10-27-2005, 12:14 PM   #2
Ihaveno
LQ Newbie
 
Registered: Oct 2005
Posts: 11

Rep: Reputation: 0
Send there a test string to see if the console responses if not dont start any connection.
You want to enable a response on the other console?
 
Old 10-27-2005, 12:31 PM   #3
jaimese
LQ Newbie
 
Registered: Oct 2005
Posts: 11

Original Poster
Rep: Reputation: 0
Hi,

I don´t know how to send an string to the console without opening a session. In this case exists network communication with the device, it responses to the ping. This is the first thing I check. After it, and checked the connectivity, I try to open the console but if it fails, nothing goes on.

This is my problem... Anyway if there is any chance to check the console itself, I can avoid the connection. I know this is not usual in network devices but mines are, how to say, a little special since they can have the network interface working and the firmware, wich the console is located, hanged.

I´m not sure to understand what your question is about. From my point of view, there are two options, what u say or have a control process that kill the connection if after some time, is unsuccesfull. I prefer the last one, but the other can be also a good solution.

If u have some code or u can detail more your idea, I will thank u a lot.

Jaime.
 
Old 10-27-2005, 12:51 PM   #4
jaimese
LQ Newbie
 
Registered: Oct 2005
Posts: 11

Original Poster
Rep: Reputation: 0
I've forgotten something important, I´m writing the script in linux bash.

Thanks
 
Old 10-27-2005, 01:01 PM   #5
Ihaveno
LQ Newbie
 
Registered: Oct 2005
Posts: 11

Rep: Reputation: 0
You are now solving a problem that i will have in 5-7 weeks in my project.But first i must program my own program to see the complete code and understand the proceses and signals+some funcion like fork.Sorry if i didnt help you but im sure in 5-7 weeks i will have much more say to you.
 
Old 10-28-2005, 01:48 AM   #6
jaimese
LQ Newbie
 
Registered: Oct 2005
Posts: 11

Original Poster
Rep: Reputation: 0
Hi!,

I've solved this problem last night making a second control process that manage the console connection, cheking it and closing if after a time, it has no results. The code is more or less the following:

console_control ()

{

limit=$1

for (( z=0; z <= limit; z++))
do
sleep 5
if [ -s $2 ]
then
return 0
fi
done

clean_console

}

clean_console ()
{

echo "Verificando consolas abiertas"

idcon=$(ps -ef | grep $eq | grep -v 'grep' | grep -v 'ping'| sed -e 's,\t, ,g' - e 's, *, ,g' | cut -f3 -d ' ')

if [ -z $idcon ] 2>/dev/null
then
echo "No se han detectado consolas abiertas"
else
kill -9 $idcon 2>/dev/null
fi

}


(
(
code to be done in the console
)
telnet xx.xx.xx.xx >> text.txt
)&
(console_control $tpo_p text.txt)&

wait
 
  


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
SQL Stored Procedures paddyjoy Programming 1 09-29-2005 11:42 AM
Question about GCC linking procedures... vinculum Programming 3 09-26-2005 08:20 AM
steps and procedures archangel Linux - General 1 08-07-2004 12:48 AM
Proftpd commands and procedures to limit Radicalm16 Linux - Software 1 12-24-2003 08:34 PM
Qt and installation procedures? Infamous Tim Linux - Software 4 04-21-2002 02:09 AM

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

All times are GMT -5. The time now is 04:34 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