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 05-24-2007, 01:00 PM   #1
energiya
Member
 
Registered: Feb 2007
Distribution: Zenwalk
Posts: 30

Rep: Reputation: 15
[Solved] Help with a daemon or a better idea


Hi,
I tried to make a small script that will be executed by irexec when I press a remote key. I wanted to make it execute something else when I press it more than 2 seconds. I came to this (not finished):
Code:
#!/bin/sh

file="/home/energiya/.remote"
time=2
times=8

vs=`date +%s`

function write_data
{
	echo $vnr > $file
	echo $vs >> $file
}

function check_number
{
	exec 3< $file
	read <&3 vnr
	read <&3 s
	sub=$(($vs - $s))
	if [ $sub -gt 10 ]; then
	  write_data
	else
	  if [ $sub -lt $time ]; then
	    vnr=$(expr $vnr + 1)
	    echo $vnr > $file
  	    echo $s >> $file
	  else
  	  {
	    if [ $vnr -gt $times ]; then
	      sub=$(($vs - $s))
	      echo $vnr $sub
	      echo "**********************************"
	    fi
	    vnr=0
	    write_data
	  }
	  fi
	  echo $vnr
	fi
}

if [ -e $file ]; then
  check_number
else
  write_data
fi
The thing is that it writes to the hdd every time I press a remote key and it writes a lot when I keep it pressed, so I'm now thinking a daemon will be better. But how do I build a daemon that can recive input from irexec? I don't care in what programming/scriping language it's made... I can handle it. I want it to be able to modify the values in memory and not write it to the hdd.

Could someone please help?
Thanks in advance!

Last edited by energiya; 05-25-2007 at 03:16 PM. Reason: Solved
 
Old 05-25-2007, 03:15 PM   #2
energiya
Member
 
Registered: Feb 2007
Distribution: Zenwalk
Posts: 30

Original Poster
Rep: Reputation: 15
Made myself the daemon in C, so problem solved
 
  


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
Good idea/bad idea: interface colors introuble General 5 10-30-2006 01:33 PM
LXer: Freespire: Great Idea? Awful Idea? LXer Syndicated Linux News 1 05-04-2006 06:10 AM
mp3 jukebox idea (different idea then I have seen) supradrvr Linux - Software 8 03-27-2006 07:58 PM
any idea... kazuni Linux - Newbie 4 05-23-2003 03:17 PM
an Idea balam Linux - Newbie 1 02-01-2003 04:53 PM

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

All times are GMT -5. The time now is 12:26 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