ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.