LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-21-2004, 01:30 AM   #1
provkitir
Member
 
Registered: Jul 2004
Location: Mass
Distribution: Freebsd 5.3, Debian sid 2.6.7
Posts: 101

Rep: Reputation: 15
2 simple shell prog questions


hi all
i'm runnin debian 2.6.9 sid fluxbox and idesk and editin for my own menus and configs
for ease i made the idesk icons to execute on single click, but i also have a shutdown button that i'd like to have a confirmation window before it executes sudo /sbin/shutdown -h now. could some one help me write a shell script that does this?
i'm guessin it's somethin like..
sh -c 'if [xmessage -center -buttons OK:1,Cancel:0 -default OK "Are you sure you want to shutdown?"] then sudo /sbin/reboot fi'
or somthing, i'm a total newbie on shell

second question, i like eyecandy, but only when they don't get in the way so i don't load them at xinit. programs such as fbpager -w. now i'd like to check that the fbpager is already running when i click on fbpager in my flux menu. if it's already running, then don't run, else, do run. it feels like it's simple enough

thanks a lot!
 
Old 11-22-2004, 04:45 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
First question: yes, it's something along those lines. I'm sure you'll manage this. But were I you, I'd write a script, instead of putting all in the command to run.

Second question:
if [ -z "$(ps -e | grep -F "fbpager" | grep -v grep)" ]; then fbpager; fi

Yves
 
Old 11-22-2004, 11:39 PM   #3
provkitir
Member
 
Registered: Jul 2004
Location: Mass
Distribution: Freebsd 5.3, Debian sid 2.6.7
Posts: 101

Original Poster
Rep: Reputation: 15
Thanks a lot!

your scripts are working great!

in case anyone cares, I found answer to 1 to be:

if echo "Shutdown System?" | col -x | xmessage -center -buttons No:1,Yes:0 -default Yes -file - ;
then sudo /sbin/shutdown -h now ; fi

probably incredibly crude but works

thanks again!
 
Old 11-23-2004, 03:00 AM   #4
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
Nice of you to give feedback And I wouldn't say your solution to #1 is crude. There may be other ways, but this one seems OK (I did not know the "col" command).

Yves.
 
  


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
how to write a simple c prog to call a script RajRed Programming 1 10-05-2005 05:10 PM
Simple polygon area c++ prog. problems Hal Programming 4 08-28-2004 08:09 AM
Two simple questions...shell scrips and icons vdogvictor Linux - General 4 04-12-2004 05:49 PM
Something wrong with this simple hello world prog mandrakeroot Programming 9 08-26-2003 05:24 PM
shell prog souvik Programming 0 05-22-2001 02:04 AM


All times are GMT -5. The time now is 05:03 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration