DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2011-01-11 11:53:17

breasthead
Member
Registered: 2009-02-05
Posts: 38

Run scripts through Windows

Hi guys,

I have a somewhat off topic question, but I'm hoping someone can tell me a yes/no about remotely running scripts on the dlink 323.

If I have a script stored somewhere on the dlink box, which is in a shared folder accessible via a windows laptop, can I make it so that by double-clicking it through windows explorer it will run some commands on my dlink?

Basically, I have terminal experience, and am able to ssh into the box and do what I need for maintenance etc.. but the rest of the users don't have a clue. I was hoping that I can write a script in some way so that simply double-clicking it through windows will make it automatically run some terminal commands on the dlink itself. This way I can create a suite of "troubleshooting" scripts which others can simply click and run in my absence.

Can this be done?

Cheers,
B

Offline

 

#2 2011-01-11 16:11:11

Mijzelf
Member / Developer
Registered: 2008-07-05
Posts: 709

Re: Run scripts through Windows

Well, sort of. You could write a php script, and by doubleclicking a link in a webinterface the script will be executed on the server. The NAS in this case.

Edit: Another option is to create a cmd file, executable on the Windows machine, which actually does something like

Code:

ssh -i private_key username@<ip-of-nas> script_to_be_executed_on_the_nas

Last edited by Mijzelf (2011-01-11 16:14:30)

Offline

 

#3 2011-01-12 08:58:43

chriso
Member
Registered: 2009-03-29
Posts: 74

Re: Run scripts through Windows

Another way to do the same thing is by having a script running on the DNS-323 and have it look for a file(s) and/or the contents of such files do something when it sees this.

For instance I have a script running on my DNS-323 that is for my backups, and it is constantly looking for a "start" file in a startBackup directory.  So on the Windows side you create a script that when double clicked just creates the "start" file in the startBackup directory and off it goes.  You could get really as fancy as you like, passing information back and forth through files, use a program with a GUI or whatever you like.

It has other key files it looks for too, like a shutdown file, that when it sees it it shutdowns down the DNS-323.  You can have it look for the contents of the file and only have one file (or say one per person), but if you are just using a regular script on the DNS-323 side it is a real easy test to see if a file exists or not.

Please note that I run my ffp from a USB drive so I don't worry about my hard drives spinning down and such.

Last edited by chriso (2011-01-12 09:01:43)

Offline

 

#4 2011-01-12 09:53:40

breasthead
Member
Registered: 2009-02-05
Posts: 38

Re: Run scripts through Windows

Thanks for the suggestions,

I think that I'll try making the cmd file and get it to ssh and execute my scripts

Cheers,
B


UPDATE:

In case anyone cares (or I forget and need to look it up again), this is how i'm doing it.

1. Write a normal shell script to do a certain task, store on the dlink and make it executable.
2. Download plink and store on the dlink.
3. Write a simple 1 line .bat file to ssh and execute the script.
The contents of the .bat file simply adds the location of plink (mounted in windows) to the Windows path, then runs the script:

Code:

set PATH=X:\path\to\plink;%PATH%
plink -ssh -pw <PASSWORD> <USER>@<NAS IP> /path/to/script/on/NAS/script.sh

This now lets anyone double click the .bat file and off it goes.

Thanks to Mijzelf for methodology.

Last edited by breasthead (2011-01-12 11:59:29)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB