LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-16-2010, 02:59 PM   #1
jonnybignote
LQ Newbie
 
Registered: Aug 2010
Posts: 5

Rep: Reputation: 0
basic return value help


Hi all
At the end of my daily cron jobs, (4am) I'm performing a reboot.

currently it does this regardless of machine status

I'd like to run it with a loop that will query 'mythshutdown --check' and proceed to reboot only if there is no recording or other activity in Mythtv. Return value 0 means ok to shutdown and value 1 means not.

Apologies for my very basic scripting knowledge as I'm sure this is very rudimentary, but here is what I have...

Code:
#!/bin/sh
while    
mythshutdown --check
do
sleep 10
done
sudo reboot
Currently the script is working in reverse so I think I either need to specify the return value or approach in another way.

Any help greatly appreciated

Thanks
 
Old 09-16-2010, 03:13 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

There are other ways to solve your problem, here's one that is based on what you have:
Code:
#!/bin/sh
while ! ./mythshutdown --check
do
sleep 10
done
sudo reboot
Hope this helps.
 
Old 09-16-2010, 04:49 PM   #3
jonnybignote
LQ Newbie
 
Registered: Aug 2010
Posts: 5

Original Poster
Rep: Reputation: 0
perfect! - thanks

so does the '!' reverse the return value of the mythshutdown -- ?

either way that's exactly what I wanted

thanks again!
 
Old 09-17-2010, 12:58 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

The ! stands for not. It reverses the way the while statement works it doesn't touch the values generated by your script.

BTW: You're welcome
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
dpkg return error :post installation script return an error code (1) grimfold Debian 2 09-10-2009 01:55 PM
GnuCash, KMyMoney - basic, basic questions - please help if you can. brjoon1021 Linux - Software 3 10-20-2008 06:27 PM
return 0 or return(0) in C? servnov Programming 5 01-08-2005 04:39 PM
return linuxanswer Programming 4 10-25-2003 11:31 PM
I'm a BASIC chap, looking for some info on BASIC programming CragStar Programming 2 01-21-2001 09:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:44 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
Open Source Consulting | Domain Registration