LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-28-2012, 12:53 PM   #1
adeoux
LQ Newbie
 
Registered: Apr 2012
Posts: 2

Rep: Reputation: Disabled
How to: run bash file in Linux which is initiated from a Windows/Mac system


Hi,

The project I'm working on now requires a user, who knows nothing about Linux, to run a couple of very simple commands in order to mount and unmount a device.
In addition, the Linux system will be behaving more like an appliance than a computer.

My ultimate goal: User on either a Mac or PC double clicks on a batch file. This batch file initiates a bash file stored on the Linux box, which contains the commands necessary. Note that the bash file would execute internally - not on the PC or Mac.

Here's a little more detail:
I am imagining using samba to share out a folder on the Linux system containing these bash files. The user would map this share on their PC or Mac. Next, they would run local batch files that would execute the bash files on the Linux system.

To be even more difficult, I am looking for a solution that doesn't require any additional software to be installed on the PC or Mac (such as Cygwin). The idea being that the customer can power on the Linux system, connect it to their network, map the samba share and be ready to go.

I've tried searching on Google for a long while but haven't found an answer yet.
I am very new to Linux (been playing with it for 3 days now), so I may be dreaming up something that isn't possible. What do you think?
 
Old 04-28-2012, 01:17 PM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
in general you may construct a server on the linux which listens to commands coming from anywhere. telnet exists on windows and mac, so you can initiate the job with telnet.
mounting can be done automatically.
 
Old 04-28-2012, 01:24 PM   #3
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by adeoux View Post
User on either a Mac or PC double clicks on a batch file. This batch file initiates a bash file stored on the Linux box, which contains the commands necessary
.. run on the Linux box, of course. Understood.

Quote:
Originally Posted by adeoux View Post
To be even more difficult, I am looking for a solution that doesn't require any additional software to be installed on the PC or Mac (such as Cygwin).
I can see four approaches:
  1. Use a telnet connection to connect to the Linux box.
    Both Windows and Mac (and most Linux distributions) come with a Telnet client built-in.
    The downside is that the connection is unprotected. This is a good option if you don't need any security for the connection.
  2. Use an SSH connection to connect to the Linux box.
    Mac OS X has an SSH client builtin, Windows does not. Fortunately, PuTTY is a standalone self-contained executable you can use (no installation needed). In this case, you can use a pregenerated RSA key to securely login to the Linux appliance.
  3. Use platform-dependent software to trigger the connection.
    You might be able to use say a Java program (on all architectures) to connect to the Linux appliance, and trigger the action.
  4. Monitor a folder for changes on the Linux side, and use that as the trigger.
    In Linux, you can use e.g. the inotifywait command in a script to monitor changes in a designated directory. You could have a script that sleeps in the inotifywait command (thus consuming no CPU, just a bit of RAM), until something happens on the monitored directory. You could have the files in that directory specify "action" parameters (if your scripts need any), and the Linux side remove the file when it has been acted upon.

You can automatically trigger any action on the Linux side when a user mounts a Linux share, or unmounts it; see the preexec and postexec Samba options, respectively.
 
Old 04-28-2012, 05:05 PM   #4
adeoux
LQ Newbie
 
Registered: Apr 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Nominal Animal,

inotifywait is working wonderfully! Thanks very much for the ideas. I'm not sure what I will use in the end, but your list certainly will keep me moving for now.
 
Old 04-28-2012, 05:40 PM   #5
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
In addition, whenever a user connects and is authenticated, a message is written into the smbd.log file. That is a message like this:
Code:
check_ntlm_password:  authentication for user [rbergsma] -> [rbergsma] -> [rbergsma] succeeded
[2012/04/25 12:21:12,  2] rpc_server/srv_samr_nt.c:_samr_LookupDomain(3490)
  Returning domain sid for domain RNB -> S-1-5-21-1724048653-3052807492-3755475192
You could execute a tail -f on the log file, read it into your script, process the log file lines and take action when something interesting happens.

I am proposing this since you said you wanted to take action when a user connected to a share.

Advantage of this solution is that nothing at all has to be done on the client. Detection is completely server side.

jlinkels
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why a windows programe(*.exe) can't run in a Linux system? prerp Linux - General 32 11-18-2008 07:20 PM
Is it possible to run Mac and Windows Applications on Fedora 9? Or any Linux? RyanConnarton Linux - Newbie 6 03-04-2008 07:41 PM
LXer: How To Run Windows And Linux On A Single System LXer Syndicated Linux News 0 02-13-2007 04:16 AM
LXer: Linux/Mac/Windows file name friction LXer Syndicated Linux News 0 07-10-2006 02:21 PM
can linux and windows me run on the same system? Darkone Linux - Newbie 4 05-23-2001 12:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration