Recurring Startup Application

Hi
Kindly refer to following post:
http://www.linuxforums.org/forum/pro...tml#post954718
Here, at post #4, solution given by "LSalab" worked for me. So I added it to startup applications in my cinnamon desktop. But the problem is that, it works only once after every login (when the battery gets lower than 10% so it informs me), and if I charge the battery and again it reaches that threshold point of 10%, the system does not inform me, which means that the startup script only executes once.
here is the script:
Code:
#!/bin/bash
while [[ `acpi | cut -d ' ' -f 4 | grep -Po '\d+'` -gt 10 ]]
do echo -ne "\r`acpi`"
sleep 5
done
notify-send -t 60000 'Low Battery' 'Battery charging of your system is below 10%. Kindly Plug charger. Thanks.'
echo ''
mplayer /usr/share/sounds/freedesktop/stereo/phone-outgoing-busy.oga -loop 0

So my question is that, how can I make this script recurring at every threshold level?
Regards


Similar Content



Autoload Python Script At Cinnamon Login

Hi
I am using Cinnamon desktop on the top of arch linux. I wanted to load a python script at desktop login which informs me about battery stats, so I created a batterymonitor.desktop entry under ~/.config/autostart. The contents of batterymonitor.desktop a
Code:
[Desktop Entry]
Type=Application
Exec=python /home/<myusername>/scripts/battery_monitor.py
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=BatteryMonitor
Name=BatteryMonitor
Comment[en_US]=
Comment=
X-GNOME-Autostart-Delay=0

But the problem is that the script is not loading at cinnamon login. I have also confirmed that the script is executable.
Can you help to load this script at cinnamon login?
Regards

Help With 'CASE'

Hi guys,

i'm beginner with Unix, I tried my best, but I Really don't know how to finish it .

here's my problem : I have to do something like Student system - student's name | subjects | mark |credits.

after starting script it will ask you for Student's name, then which subject, then the mark will appear.

It's a homework, and I have my own idea how to solve it, but cannot finish it, i don't want complete solution, just a help!

Code:
#!/bin/bash
echo "Students name"
echo -n "Enter student's name: "
read name
echo
case $name in
Example1|Math) echo "C" ;;
Example2|Programming) echo "D" ;;
Example3|WWW) echo "A" ;;
Example4|Economie) echo "-" ;;
esac

I don't now how to bring together case with second things which is "enter subject".

I appreciate any help

Script Persistently Lowering Mplayer Volume

I have a similar script as follows

Code:
(sleep 5m; echo "set_property volume 85 > "fifo_file")&

mplayer -volume 95 -quiet -slave -input file="fifo_file" song1 song2 song3

This makes the current song change volume to 85 after the 5 minute sleep period, but any songs after that revert to 95.

I want to keep it at volume 85 until the mplayer command completes but start at 95 until changed.

Is this possible?

Bash Script For Xfce4 Powermanager Settings Switching Forth And Backward

i need a bash script to switch to zero second on ac the waiting time for turning off the monitor (highlighten in red). same as for on battery (highlighten in purple)

Code:
<?xml version="1.0" encoding="UTF-8"?>

<channel name="xfce4-power-manager" version="1.0">
  <property name="xfce4-power-manager" type="empty">
    <property name="power-button-action" type="empty"/>
    <property name="show-tray-icon" type="empty"/>
    <property name="logind-handle-lid-switch" type="bool" value="true"/> 
    <property name="dpms-on-ac-sleep" type="uint" value="1"/>
    <property name="dpms-on-ac-off" type="uint" value="2"/> 
    <property name="brightness-on-battery" type="uint" value="9"/> 
    <property name="dpms-on-battery-sleep" type="uint" value="1"/>
    <property name="dpms-on-battery-off" type="uint" value="2"/> 
    <property name="lock-screen-suspend-hibernate" type="bool" value="false"/>
    <property name="dpms-enabled" type="bool" value="true"/>
  </property>
</channel>

Centos 7 Startup Script

I have a Centos 7 server which setup by previous system administrator , when this server startup , it will start some service eg. apache , mysql etc, but I could not find the startup script at /etc/rc.local /etc/rc.d/rc.local or /etc/rc.d/init.d , would advise which path will be the startup script keep ?

Thanks

Willingnes Parameter Change In The Protocol OLSR NS2

Hi

It's my first post,please bear with us.I write thesis "The concept of using energy metrics for route selection in OLSR routing protocol". I use the simulator ns2, and UM-OLSR patch. In tlc script I use "Energy model". How and where(in code, or tcl cript) I can change parameter "willingness" during simulation to take into account the level of battery.


pseudocode

if (battery < 1.0) && (battery > 0.8)
{willingnes = WILL_ALWAYS};
else if (battery < 0.8) && (battery > 0.4)
{willingnes = WILL_DEFAULT};
else if (battery < 0.4) && (battery > 0.2)
{willingnes = WILL_LOW};
else if (battery < 0.2)
{willingnes = WILL_NEVER};

How To Run An Application After The Boot ?

Hi, i know this could seems like a "simple" question but after a lot fo try i can't seems to make it works, i am stuck on this. I am working on a sbc6000x board, linux 2.6.24, an embedded system.

I am working on a pretty nice project which when called like this run perfectly :
Code:
cd /bin
./apps

(/bin/apps don't works, it must be ./apps from the directory)

After searching a little about the startup i learned about rc.local and created it in /etc/init.d, rc.local look like this :

Code:
#!bin/sh
# /etc/rc.d/rc.local: Local system initialization script.
#

cd /bin
./apps
cd

Sadly it seems it is never called. I was thinking about maybe add cd /bin, /.apps to the end of the etc/profile but i don't know if profile can run command aside from simple scripts call.

Does anyone has an idea on why this don't work or on how i could do this ?

Basic Bash Script

Code:
PREFIX=192.168.1
OCTET=1
while [ $OCTET -lt "255" ]; do
    echo -en "Pinging ${PREFIX}.${OCTET}..."
    ping -c1 -w1 ${PREFIX}.${OCTET} > /dev/null 2>&1
    if [ "$?" -eq "0" ]; then
       echo "OK"
    else
       echo "Failed"
    fi
    let OCTET=$OCTET+1
done

My question is, in the penultimate line, why is it OCTET, and not $OCTET, with a dollar before it, meaning, the variable?

What if it were written:
Code:
let $OCTET=$OCTET+1

Like in C++ (I think) or Python or whatever?

Best Way To Run Two Interdependent Scripts

Hi All,

I have two scripts, the aim of these two scripts is, to check whether a particular script is running or not, if it wont runs, then throw a mail.

How i Achieved this output is, I wrote first script.

I created an infinite while loop which performs below steps

1. It creates a touch file
2. Triggers the script which needs to be monitored if its working or not.
3. Removes the touch file.

If the second step fails, then the remove file command will not happen and the script will stuck there itself.

I created an another script which checks the creation time of the touch file and if it is more than ten minutes, it means the second step in the first script is hanged, which also means that particular script is not working.

So if the creation time is more than 2 minutes the second script will throw a mail.

Below are the two scripts.

Code:
#!/bin/ksh



userid="chansd"

filename="/apps/log/check.txt"

while true ;do
touch $filename
pass=`/apps/eDMZ/call_st.ksh $userid`
sleep 20
rm $filename
done

Below script checks the file creation time and throws email if it is older than 2 minutes
Code:
#!/bin/ksh


filename="/apps/log/check.txt"

if [ -f "${filename}" ]
then
if test "`find $filename -mmin +2`"
then
echo "script is not working ! Please act on it" | mail -s "Script  is not working" Example@mail.com
fi


else

        exit 1

fi


What im going to do is

1. I am going to run the first script in background so it runs forever.
2. I am going to run the second script in cron forevry 5 mins to check the file creation time.

3. So if the first script hangs . I will kill the process using process id and after the issue resolves with the inner script, I will run the main script again.

I am new to Linux, Please let me know if this approach will work as expected.

Cron Ignoring Changes Made In File

Hi,

i have a small problem on my system... I recently wrote a small bash script and added it via crontab -u root -e and it's executed as it should.
Then a few days after i did edit my bash script, but once it is run by cron it doesn't reflect the changes i made to the script. I did manually restart crond, tryed sync, moved my script, renamed it even rstart the server - no success.
If i run my script manually it returns me the expected output.
part of my script (/root/sd.sh):
Code:
#!/bin/sh

echo -n "Checking Raid... "
RAID=`tw-cli /c0/u0 show status | cut -c17-31 | grep -ci OK`
RAIDSTATUS=`tw-cli /c0/u0 show status | head -n1 | cut -c17-31`
if [ $RAID -eq 0 ]; then
  VERIFYING=`tw-cli /c0/u0 show status | cut -c17-31 | grep -ci VERIFYING`
  REBUILDING=`tw-cli /c0/u0 show status | cut -c17-31 | grep -ci REBUILDING`
  if [ $VERIFYING -eq 1 ]; then
    CURRENTSTATUS=`tw-cli /c0/u0 show verifystatus | head -n1 | cut -c46-49`
  fi
  if [ $REBUILDING -eq 1 ]; then
    CURRENTSTATUS=`tw-cli /c0/u0 show rebuildstatus | head -n1 | cut -c47-50`
  fi
  echo "Raid is busy (Raid $RAIDSTATUS$CURRENTSTATUS)"
  exit 1
fi
echo "Raid is idle (Raid $RAIDSTATUS)"

echo -n "Checking for logged in Users... "
USERS=`who | wc -l`
if [ $USERS -gt 0 ]; then
  echo "Users online"
  exit 1
fi
echo "None logged in"

crontab -l :
Code:
root@monster:~# crontab -l
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
*/10 * * * * /root/sd.sh | logger
*/30 * * * * /root/dropbox.sh > /dev/null

syslog:
Code:
Mar 21 09:10:01 monster /USR/SBIN/CRON[3998]: (root) CMD (/root/sd.sh | logger)
Mar 21 09:10:01 monster logger: Checking Raid... Raid is busy (Raid )
Mar 21 09:17:01 monster /USR/SBIN/CRON[4045]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 21 09:20:01 monster /USR/SBIN/CRON[4105]: (root) CMD (/root/sd.sh | logger)
Mar 21 09:20:01 monster logger: Checking Raid... Raid is busy (Raid )
Mar 21 09:30:01 monster /USR/SBIN/CRON[4266]: (root) CMD (/root/sd.sh | logger)
Mar 21 09:30:01 monster /USR/SBIN/CRON[4265]: (root) CMD (/root/dropbox.sh > /dev/null)
Mar 21 09:30:01 monster logger: Checking Raid... Raid is busy (Raid )

when i run sh /root/sd.sh
Code:
root@monster:~# sh /root/sd.sh
Checking Raid... Raid is idle (Raid OK)
Checking for logged in Users... Users online
root@monster:~#

Any ideas why? - any help or thoughts appreciated

regards
Pat