Sending a Signal from windows to linux to run the script

Core libraries and systems
Post Reply
Message
Author
A Gobiraj
Posts: 7
Joined: Fri 16 Aug 2013, 02:23

Sending a Signal from windows to linux to run the script

#1 Post by A Gobiraj »

Hi All,

I need desperate help to run the shell script on Linux from windows PC .
I only have script on Linux which is used to kill the process on Linux but that script needs to be run from windows.

So can some one please help me out how to start solving this issue as I have zero knowledge on this. Some how I wanted understand the whole concept from one of good explanation from anyone else.

Thanks
Gobi

User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#2 Post by Nathan F »

Two things come to mind at present.

Install Putty on your Windows PC and use it to ssh into the Linux box. Probably easier.

The second would be to put a watch on a file using something like "inotifywait". If you access the file it sends a signal to the process watching it, which can then run some code. You could use ftp, sftp, or even samba to access the watched file.

The code for doing this with "inotifywait" is fairly simple:

Code: Select all

inotifywait -m -e access <some-file> | while read EVENT
do <some command>
done
Replacing <some file> and <some command> with the watched file and the command you want to run. Note that this method will keep the inotifywait program running as a background daemon until you kill it. If you only want to execute the script once, leave out the -m option.
Bring on the locusts ...

A Gobiraj
Posts: 7
Joined: Fri 16 Aug 2013, 02:23

#3 Post by A Gobiraj »

Hi Nathan,
Thanks for your prompt reply. The script file in the Linux needs to be executed from windows with some conditions. But I know C but I do have zero knowledge in handling the systems. I couldn't about watchfiles which you have mentioned.

But this my plan I need to write down exe file in C on windows which should control the script on Linux .

if { send the signal to Linux to execute the script}

else
{ nothing}

but I don't know how to call the signals in C and which signal needs to be called. Also I even don't know how to interface with Linux system to send this signal to execute the script. ( all our pcs are connected via intranet)
Thanks
Gobi

User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#4 Post by Nathan F »

Just to clarify then, do you need to have a windows program communicate with a linux program? Or is it enough to just be able to control the program from the windows computer?
Bring on the locusts ...

A Gobiraj
Posts: 7
Joined: Fri 16 Aug 2013, 02:23

#5 Post by A Gobiraj »

Hi Nathan,

I just want to control the process on Linux from windows PC.

User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#6 Post by Nathan F »

Then easy, install Putty and use ssh to log into your linux pc.
http://www.chiark.greenend.org.uk/~sgta ... on a LAN.
Bring on the locusts ...

A Gobiraj
Posts: 7
Joined: Fri 16 Aug 2013, 02:23

#7 Post by A Gobiraj »

HI Nathan,

any comments??

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#8 Post by 8-bit »

A Gobiraj wrote:Hi Nathan,

I just want to control the process on Linux from windows PC.
Since linux and windows use different base kernels and linux uses script files while windows uses batch files, getting windows to understand and execute a linux script file would be rough.
If one can transfer a control file/application/script to linux in such a way that th file is executed by the linux box, then you have a door.
But there is the rub.
Figuring out where to place the file with instructions to the kernel to execute said file and the file having the executable parameters set.

Lets say that one was able to place an executable into the Startup folder in linux from windows.
On a reboot of the linux system, the file would execute if its parameters had been set correctly.

If I may ask though, what is your purpose of wanting to be able to execute a file on a networked linux box using windows??

User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#9 Post by Nathan F »

Don't know what happened there...

What I had type before was just reiterating that Putty is probably a good solution for what you need. It's a Windows program that includes a terminal and ssh client.
http://www.chiark.greenend.org.uk/~sgta ... nload.html
You'll need an ssh server running on the linux pc. Dropbear is a good solution if it's only going to be used over the LAN.

With that setup you can log into your Linux PC from the Windows PC and run any commands you wish.
Bring on the locusts ...

A Gobiraj
Posts: 7
Joined: Fri 16 Aug 2013, 02:23

#10 Post by A Gobiraj »

Hi Nathan,
So using putty and SSH server can I still invoke the script on Linux automatically using some code not manually.

User avatar
Nathan F
Posts: 1764
Joined: Wed 08 Jun 2005, 14:45
Location: Wadsworth, OH (occasionally home)
Contact:

#11 Post by Nathan F »

Well, that's what I was asking about before. If you want to have some program in windows control some program on a linux conputer, that's beyond the scope of what I mentioned.
Bring on the locusts ...

A Gobiraj
Posts: 7
Joined: Fri 16 Aug 2013, 02:23

#12 Post by A Gobiraj »

Actually we have two system for our Simulator system.
one with Linux and other one with windows. now we have some issue on Linux part of the simulator but we need to restart the process on Linux after we have some certain number of runs on windows PC. Because windows PC is the controller so that execution should be decided by the widows PC after the certain period of times.

A Gobiraj
Posts: 7
Joined: Fri 16 Aug 2013, 02:23

#13 Post by A Gobiraj »

But this my plan I need to write down some coding on windows which should control the script on Linux .

if { then send the signal to Linux to execute the script}

else
{ nothing}

but I don't know how to call the signals in C and which signal needs to be called. Also I even don't know how to interface with Linux system to send this signal to execute the script. ( all our pcs are connected via intranet)

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#14 Post by 8-bit »

What about having the linux script check for a ping or a sequence of them and act on that as a switch?
I am not sure if one could use the pings as a sort of morse code.
But having the linux script look for pings is a thought.

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

#15 Post by akash_rawal »

You can use TCP connections. This works whenever both computers are connected via network/internet.

On linux end you could use nc to listen at a particular port number, say 1234:

Code: Select all

nc -l -p 1234
On windows computer you have to open a TCP connection to the linux computer and write the message.

nc command running in linux machine will then output the message and exit. Then your script could evaluate the message and execute commands and optionally start all over again.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#16 Post by Karl Godt »

No idea how to code scrips on Windows .
I installed http://www.cygwin.com/install.html and am running
find command when Windows search gets on my nerves or
wget -c if downloads by Firefox disrupt
from it's bash shell .
It's a learning curve, though !
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P

Post Reply