Run a linux command from a Windows desktop shortcut or script?

w1z4rd

Karmic Sangoma
Joined
Jan 17, 2005
Messages
49,747
Im not sure if this is even possible.

The problem: Our one company uses a crap old database system to manage its stocks. This database is a flat file that is stored on a normal windows samba share. Sometimes the db gets locked (like has a ghost session) and only restarting smb will kill the connection and allow the user to login again.

What I need to be able to do is allow a certain end user (and I mean really end user), to double click something on their desktop that will restart the smb service.

I have no idea how to do this... Im thinking perhaps its possible to do a script or to write a php file that will restart the smb service?

Any ideas on how to go about this?
 

HazMan

Well-Known Member
Joined
Feb 17, 2009
Messages
208
Hi w1z

Not too sure, but maybe something like this ?

you can use Plink (part of PuTTY) with the -m parameter, and it will execute the local script on the remote server.

plink root@Machine -m local_script.sh

Haz
 

HazMan

Well-Known Member
Joined
Feb 17, 2009
Messages
208
No prob - but don't thank me - as always, Google was my friend ;)
 

InterGalacticSpook

Well-Known Member
Joined
Mar 28, 2011
Messages
130
<?php
/* Yo,
a tad bored, so slapped this together for you if still having the problem,
run it as a cronjob`ber each morning so any dead locks..

See, the ghost are the bad guys, couldnt resit :)

Igs
*/

date_default_timezone_set('Africa/Johannesburg');



echo 'Start Killing the buggers: '; #, duration(),"\n";



$MyService = "service smb restart";

$MyProgram = "pkill -u Appuser"; // <-- change use name ... toggle user


execute();

echo 'They dead now: '; #, duration(),"\n";



function execute() {

global $MyProgram, $MyService;



$RunCommand = " $MyService $MyProgram" ;

passthru ("$RunCommand");

}

?>
 

nivek

Honorary Master
Joined
Mar 25, 2005
Messages
10,271
You could probably just point some specifically created user in the /etc/passwd to use a batch script to do the reset as their shell (just replace their /bin/bash in the entry to /bin/resetwhatever), and then use netcat to telnet to the server and login using that user, but you'd obv have to enable telnet, not really an issue if its on a private network
 

Nod

Honorary Master
Joined
Jul 22, 2005
Messages
10,057
You could probably just point some specifically created user in the /etc/passwd to use a batch script to do the reset as their shell (just replace their /bin/bash in the entry to /bin/resetwhatever), and then use netcat to telnet to the server and login using that user, but you'd obv have to enable telnet, not really an issue if its on a private network

ssh might be easier:
Code:
ssh -CX root@machine "service samba restart"
This is assuming that the correct keys was set up. Might not be too safe for normal users.

First prize would be to figure out who/what is locking the file.
It is always better to solve the cause, rather than the symptom.
 
Top