Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 20 Oct 2014, 05:59
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » System
Sending a Signal from windows to linux to run the script
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [16 Posts]   Goto page: 1, 2 Next
Author Message
A Gobiraj

Joined: 15 Aug 2013
Posts: 7

PostPosted: Thu 15 Aug 2013, 22:28    Post subject:  Sending a Signal from windows to linux to run the script  

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
Back to top
View user's profile Send private message 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: Fri 16 Aug 2013, 00:02    Post subject:  

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:
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 ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
A Gobiraj

Joined: 15 Aug 2013
Posts: 7

PostPosted: Fri 16 Aug 2013, 01:53    Post subject:  

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
Back to top
View user's profile Send private message 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: Fri 16 Aug 2013, 02:01    Post subject:  

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 ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
A Gobiraj

Joined: 15 Aug 2013
Posts: 7

PostPosted: Fri 16 Aug 2013, 02:13    Post subject:  

Hi Nathan,

I just want to control the process on Linux from windows PC.
Back to top
View user's profile Send private message 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: Fri 16 Aug 2013, 02:38    Post subject:  


_________________
Bring on the locusts ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
A Gobiraj

Joined: 15 Aug 2013
Posts: 7

PostPosted: Fri 16 Aug 2013, 03:13    Post subject:  

HI Nathan,

any comments??
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3380
Location: Oregon

PostPosted: Fri 16 Aug 2013, 03:40    Post subject:  

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??
Back to top
View user's profile Send private message 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: Fri 16 Aug 2013, 03:41    Post subject:  

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/~sgtatham/putty/download.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 ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
A Gobiraj

Joined: 15 Aug 2013
Posts: 7

PostPosted: Fri 16 Aug 2013, 04:01    Post subject:  

Hi Nathan,
So using putty and SSH server can I still invoke the script on Linux automatically using some code not manually.
Back to top
View user's profile Send private message 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: Fri 16 Aug 2013, 04:06    Post subject:  

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 ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
A Gobiraj

Joined: 15 Aug 2013
Posts: 7

PostPosted: Fri 16 Aug 2013, 04:08    Post subject:  

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.
Back to top
View user's profile Send private message 
A Gobiraj

Joined: 15 Aug 2013
Posts: 7

PostPosted: Fri 16 Aug 2013, 04:11    Post subject:  

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)
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3380
Location: Oregon

PostPosted: Sat 17 Aug 2013, 00:30    Post subject:  

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.
Back to top
View user's profile Send private message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Sat 17 Aug 2013, 14:01    Post subject:  

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:

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.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [16 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » System
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0770s ][ Queries: 11 (0.0044s) ][ GZIP on ]