AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Run a script on a remote computer

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Pallie



Joined: 05 Jul 2004
Posts: 57
Location: London

PostPosted: Mon Feb 21, 2005 2:54 pm    Post subject: Run a script on a remote computer Reply with quote

I wanted to be able to run a script on a remote computer over the local network. This example is so that I can mute the sound on the PC on the computer upstairs from the laptop downstairs. Until now I used VNC to do it. Thought I'd share it in case anyone wanted to do anything similar.

I managed to do it by installing a web server on the PC upstairs. Sounds a bit like overkill, but there is a great free server available at

http://www.aprelium.com/abyssws/index.html

which is small and easy to manage. I had to go into the advanced configuration and set enable SSI and set the parameter to allow Exec Cmd Execution.

I created a simple web page called index.shtml in the html folder where the server installed itself
Code:
<!-- #exec cmd="mute.exe" -->
<!-- #exec cmd="type temp.txt" -->

which means that whenever this page is requested, the server will run mute.exe, then display in contents of the file temp.txt

The AHK bit is then easy. On the remote PC in the same folder I created a simple script called mute.ahk and complited it
Code:
filedelete, temp.txt
SoundGet, master_mute, , mute
fileappend, was %master_mute%`n, temp.txt
SoundSet, +1, , mute
SoundGet, master_mute, , mute
fileappend, now %master_mute%, temp.txt

This just toggles the mute and puts whe result in the text file. Then all you need is something to call it from the other PC
Code:
FileDelete, down.html
URLDownloadToFile, http://192.168.0.3/index.shtml, down.html
FileRead, Result, down.html
msgbox, %result%


or of course just type http://192.168.0.3/index.shtml in a browser. (192.168.0.3 is just the ip address of the host computer on the network).

In theory you could use something similar to run scripts over the internet. You need to be careful though, by enabling ssi command execution could allow someone to run commands on the server.

If anyone has a simpler solution I would like to know. I tried just running programs over a shared drive but could not get it to work.

Mike
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Mon Feb 21, 2005 3:50 pm    Post subject: Reply with quote

PSExec ? ---> www.sysinternals.com
Back to top
Pallie



Joined: 05 Jul 2004
Posts: 57
Location: London

PostPosted: Mon Feb 21, 2005 5:07 pm    Post subject: Reply with quote

Thanks BoBo

I think that would work. I downloaded it and tried
Code:
psexec \\192.168.0.3 c:\mute
from the command prompt and it muted the sound.

An advantage of doing it this way is that it would be easy to pass parameters over so you could say whether to toggle, mute on, mute off (which you could do with the web server but it is more complicated).

I'll create a new script and see how they compare.

Mike
Back to top
View user's profile Send private message
savage



Joined: 02 Jul 2004
Posts: 206

PostPosted: Mon Feb 21, 2005 8:12 pm    Post subject: Reply with quote

I've never gotten psexec to work right on my network, it only works if you're logged in as the same user on both computers.

I was going to suggest some kind of remote shell access using netcat on listen mode tied into cmd.exe, then you could just use netcat to connect to that computer and run whatever you want, but psexec is definitely the easier solution if it works for you Rolling Eyes .
Back to top
View user's profile Send private message AIM Address
Payam



Joined: 07 Apr 2004
Posts: 58

PostPosted: Tue Feb 22, 2005 2:23 am    Post subject: Re: Run a script on a remote computer Reply with quote

Smart. Very Smart Smile
Thanks for sharing the idea.
Payam
Pallie wrote:
I wanted to be able to run a script on a remote computer over the local network. This example is so that I can mute the sound on the PC on the computer upstairs from the laptop downstairs. Until now I used VNC to do it. Thought I'd share it in case anyone wanted to do anything similar.

I managed to do it by installing a web server on the PC upstairs. Sounds a bit like overkill, but there is a great free server available at

http://www.aprelium.com/abyssws/index.html

which is small and easy to manage. I had to go into the advanced configuration and set enable SSI and set the parameter to allow Exec Cmd Execution.

I created a simple web page called index.shtml in the html folder where the server installed itself
Code:
<!-- #exec cmd="mute.exe" -->
<!-- #exec cmd="type temp.txt" -->

which means that whenever this page is requested, the server will run mute.exe, then display in contents of the file temp.txt

The AHK bit is then easy. On the remote PC in the same folder I created a simple script called mute.ahk and complited it
Code:
filedelete, temp.txt
SoundGet, master_mute, , mute
fileappend, was %master_mute%`n, temp.txt
SoundSet, +1, , mute
SoundGet, master_mute, , mute
fileappend, now %master_mute%, temp.txt

This just toggles the mute and puts whe result in the text file. Then all you need is something to call it from the other PC
Code:
FileDelete, down.html
URLDownloadToFile, http://192.168.0.3/index.shtml, down.html
FileRead, Result, down.html
msgbox, %result%


or of course just type http://192.168.0.3/index.shtml in a browser. (192.168.0.3 is just the ip address of the host computer on the network).

In theory you could use something similar to run scripts over the internet. You need to be careful though, by enabling ssi command execution could allow someone to run commands on the server.

If anyone has a simpler solution I would like to know. I tried just running programs over a shared drive but could not get it to work.

Mike
Back to top
View user's profile Send private message Send e-mail MSN Messenger
gaurav_jain



Joined: 10 May 2005
Posts: 1

PostPosted: Tue May 10, 2005 10:52 pm    Post subject: running shell scripts on remote pc (web server) through web Reply with quote

Hello all ,
this is realy amazing to find stuff here which i am looking for, actually i am not a professional programmer but trying to be haha ,, actually i also want to do that same thing as u people doing here, I want to exexute a shell script (on linux base computer & apache web server is running on it ) & exactly as Pallie had done but my ip might be Public one,i am thinking to do it by Java script (for web page) and call that shell script which i allread had saved to that server ,,, ,,,,,,,,,,,,,,,Please help be guys i am really in need of it
i will apreciate your help........................
i am egerly wating for your reply ...........................
give me suggestion .............
by
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
TeknoMusicMan



Joined: 14 Apr 2005
Posts: 188
Location: Wisconsin, USA

PostPosted: Tue May 10, 2005 10:55 pm    Post subject: Reply with quote

gaurav_jain, you should post that in the Support/Help section, as it will get more attention there.
_________________

"Make it idiot-proof, and someone will make a better idiot."
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Guest






PostPosted: Wed May 11, 2005 2:51 am    Post subject: Reply with quote

savage wrote:
I've never gotten psexec to work right on my network, it only works if you're logged in as the same user on both computers.


Not for NT systems. You can use the -u and -p parameters with psexec. What it does, is install a "temporary" service that will execute your program or batch file on the remote machine. It runs this service using the credentials passed with -u and -p. Then when it's done, it removes the service. There is another program called Xcmd that does a similar thing and you can download the source code. This looks like it here.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group