LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-20-2008, 10:40 AM   #1
ernesto_cgf
Member
 
Registered: Nov 2003
Location: Havana, Cuba
Distribution: Ubuntu 9.04 "Jaunty Jackalope"
Posts: 153

Rep: Reputation: 30
Execute a script if on some specific network


Hi,

I have my laptop which I use in several places, but when I am at work I use it along my desktop pc. I am using Synergy to be able to use them both with the same keyboard and mouse.

The following three questions are more or less equivalent, because if I can solve some of these questions then I think I can achieve what I want.
  • Is there a way to start synergy (or an arbitrary script) automatically with certain parameters every time I connect to this network, but not on other networks?
  • Is there a way to detect from a script if the computer is on a given network.
  • Is there a way to detect if a given host (fixed ip address) is up and with a given service (tcp port) open?

Thanks in advance
 
Old 06-20-2008, 11:08 AM   #2
lsteacke
Member
 
Registered: Jul 2007
Distribution: Ubuntu
Posts: 99

Rep: Reputation: 16
Well I'm not really familiar with synergy so I can't really speak to your first question, however I do believe your next two questions can be accomplished. For finding if a computer is on a specific network, couldn't you simply write a script to grep the output of ifconfig and return a value if the network number you were looking for was found?

As for finding whether a port is open on a box, you will most likely be using telnet for that, and you could write a script to attempt to open a telnet session on whatever ports you are looking for. This seems to be the common practice for finding open ports.
 
Old 06-22-2008, 09:40 PM   #3
ernesto_cgf
Member
 
Registered: Nov 2003
Location: Havana, Cuba
Distribution: Ubuntu 9.04 "Jaunty Jackalope"
Posts: 153

Original Poster
Rep: Reputation: 30
Thanks for the ideas! I'll try first the approach of grepping the output of "ifconfig eth1" and look for clues in the interface configuration numbers. The second idea you mention around telnet is good too. I guess I will solve this now either way. Thanks again! I'll keep you posted here on my progress.
 
Old 06-23-2008, 01:42 AM   #4
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
I wrote a script a while back which did something similar, and I thought I would post a link to the thread in case it might help you.
 
  


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
How to execute a ssh script on Linux server from Windows through a bat script? wanna13e Programming 13 10-23-2009 02:41 AM
Script does not execute with cron Arty Ziff Linux - Newbie 14 05-23-2008 12:08 AM
PHP Script Does Not Execute Ukee Linux - Server 5 02-24-2008 08:00 PM
script to parse variables to curl script and execute morphix Programming 17 11-30-2007 01:27 AM
Cannot execute a script grueugene Programming 15 01-27-2005 04:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:30 PM.

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