LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-04-2010, 10:57 PM   #1
ljm
LQ Newbie
 
Registered: Jan 2010
Posts: 5

Rep: Reputation: 0
Options for running - Executable text files


I have created some text executable files and put them on my desktop.
In the way of background I created them in gedit. Then used chmod ugo+x (filename) to make them executable.
One of them is a ping test to see if a printer is on. Text in file = ping 192.168.1.50
Others are to turn my laptop touchpad on and off. text in file = sudo modprobe -i psmouse

I have 2 questions about executable text files
First question
When I click on an executable text file it present a window with 4 options (Run in terminal, display, cancel, run).
Can I set a parameter or do something else so it just runs in terminal?
I know I can set an option in Nautilus to run them but when I select run nothing seems to happen. In addition I would want to set this option on a case by case basis not globally in Nautilus.
If there is an option or flag where it would run this file in terminal I would use it on my printer ping test.

Second question
When I click on these executable text files to turn my touchpad on and off, the text within the file uses the sudo command so that requires that I input my password. After I click on either of these files a window appears with the 4 options (Run in terminal, display, cancel, run). I select run in terminal, a terminal window opens and requests my password. Subsequent to inputting my password the file executes fine.
Is there a way to set a parameter or do something else so I don't need to not only select the run in terminal option from (run in terminal, display, cancel, run) but also not to enter my password?

Thanks in advance for your assistance.
 
Old 08-04-2010, 11:47 PM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 249Reputation: 249Reputation: 249
Why not use the command line anyway ? If you insist on clicking things, create launchers for the scripts on your panel, and there is a setting to make them open in a terminal. It is not advisable to store the root password anywhere so automatic password entry is not a good idea.
 
1 members found this post helpful.
Old 08-04-2010, 11:59 PM   #3
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
Don't store the script itself on your desktop. Also, don't include sudo inside the script itself. Do this:

Code:
$ sudo touch /usr/local/bin/toggle-touchpad
$ sudo chmod u=rwx,g=rx,o=r /usr/local/bin/toggle-touchpad
Edit the file to look like this:

Code:
#!/bin/bash
modprobe -i psmouse
Then add a line to /etc/sudoers:
Code:
username ALL=(ALL) NOPASSWD: /usr/local/bin/toggle-touchpad
Or instead, do it on a group basis:
Code:
%groupname ALL=(ALL) NOPASSWD: /usr/local/bin/toggle-touchpad
Finally, create a launcher on your desktop to run the command:
Code:
sudo /usr/local/bin/toggle-touchpad
 
1 members found this post helpful.
Old 08-05-2010, 05:14 PM   #4
ljm
LQ Newbie
 
Registered: Jan 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Meson,
This may be a duplicate thanks. I went away for a minute and didn't see my reply so thank you for taking the time to write such a detailed solution.
As I mentioned in my first reply I'm learning all the time.
I looked up the touch command you used and I will use it in the future to create empty files; very useful.
I also like the idea of listing the file in sudoers so I don't need to use a password. Once again very useful.
Also I never used launcher before so that was another great find.
I may bug you from time to time if I get stuck again - hope you don't mind.
Thanks again for the support.
Best,
Lou (ljm)
 
Old 08-05-2010, 06:46 PM   #5
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
Quote:
Originally Posted by ljm View Post
I may bug you from time to time if I get stuck again - hope you don't mind.
If you want my attention, post the message publicly. You may send me a Private Message with a link to the post =)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
join 2 text files based on first number present in every line of the 2 text files markraem Linux - Software 4 01-25-2010 07:26 AM
Moving text files between Windows and Linux: Unicode and "executable" problems AchubaNanoiaBR Linux - Newbie 2 07-04-2009 05:15 PM
Executable Text Files: Disable Run Prompt? 1bloke Linux - Software 2 09-22-2007 12:47 AM
Running a Java executable class from another executable class LUB997 Programming 22 07-24-2005 05:57 AM
BASH text executable blackbox Linux - Newbie 1 02-28-2005 07:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:49 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration