Programming :: Bash Script To Toggle A Daemon (here Proftpd)?
Jan 5, 2010
I want to create a script which toggles a daemon (here proftpd). On the first execution it should start it and on the next one it should stop it but first check if proftpd is already running or not (and make the decision to start or stop on that).I have created this script:
Code:
#!/bin/sh
# proftpd-toggle
[code]...
View 14 Replies
ADVERTISEMENT
Feb 24, 2011
I have a daemon script which wakes up every 5 minutes and checks the health of started processes. It works fine during the day but throws a syntax error just after midnight.Here is the log:
(02/22-23:49) Check all started processes
(02/22-23:54) Check all started processes
(02/22-23:59) Check all started processes
[code]....
View 9 Replies
View Related
Jun 11, 2011
I'm on a Dell Inspiron 6000. I installed i8kutils and it works. Fan speed reduces CPU temp from 50C to 44C. A start-up script invokes the i8k module: $ udo /usr/sbin/modprobe i8k force=1 which creates /proc/i8k. The man page for i8kctl is straightforward: a few simple commands to read info from the aforementioned file.So. I know nothing about writing even basic bash scripts. I gave it a go here but I know this is way wrong. Would anyone like to help a guy out? This is my starting point (don't laugh):
Code:
#!/bin/bash
# script to toggle fan speed low/high
[code]...
View 5 Replies
View Related
Jun 25, 2010
I often have a need for an icon on my panel or any place that toggles between two states. Example: click the button once and it turns on the Internet (1), click the button again and it turns off the Internet(2), click the button again and it turns the Internet on again (1).The only way I know is to have a script create and delete a file. If it finds no file, it runs operation 1 and creates a file. If it finds the file, it runs operation 2 and deletes the file.
View 4 Replies
View Related
Aug 7, 2011
i've written a script that will move some files from one directory to another, i dont know if this is the right place to ask but, this is on my ipod touch and i'm wondering how to make it run periodicaly
View 6 Replies
View Related
Apr 27, 2011
I have written a daemon server. I would like to add the ability for the daemon to update itself. That is, it should be able to download the latest version of the code (when it receives a signal from a client) and then restart itself. I am stuck on getting the daemon to restart itself. The problem is killing the old daemon without killing the process that is starting the new daemon. In my latest attempt, the daemon that is updating itself runs a program in a subshell (using system) that starts a restarter daemon that runs the original daemon (again using system) with the restart command option. With the restart option, the new version of the daemon sends a terminate signal to the old version. Obviously, when I run the original daemon manually with the restart option, it restarts reliably. I figured that issuing the same restart command from a daemon would adequately isolate the process doing the restarting from the program being restarted. Using ps, I can see that the daemon does actually restart. However, the client locks. In fact, a few times, the OS locked and I had to reset.
View 7 Replies
View Related
Feb 4, 2011
I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.
View 3 Replies
View Related
Jan 24, 2010
simple bash code:
Code:
#!/bin/bash
trap "echo 'you got me'" SIGINT SIGTERM # to trap ctrl+c
echo "Press ctrl+c during 5 sec loop"
for ((i=0;i<5;i++)); do
[Code]...
How come code behaves normally and stops when ctrl+c signal is caught and resumes, but after I use at least one timeout read in the code it looks like, if signal is caught again it doesn't pause the execution but skips the loop. If you remove -t (timeout) option from the read, both loops look the same!
View 10 Replies
View Related
Nov 26, 2008
I have a config file that contains:
my.config:
Code:
Now in my bash script, I want to get the output /home/user instead of $HOME once read. So far, I have managed to get the $HOME variable but I can't get it to echo the variable. All I get is the output $HOME.
Here is my parse_cmd script:
Code:
View 3 Replies
View Related
Jul 25, 2011
I have written quite a few separate bash & scripts and php scripts that up to now I have run from cron jobs. However I have to estimate how long each takes to run, before running the next and so it probably takes much longer than necessary to run them all. They have to run in order.
Now there are so many I am thinking it would be better to have a master bash script that would run one after the other, but I am not sure how to get the master script to wait before starting to run the next script. Is this possible and is there a command that will make the script wait between bash and php scripts , for them to finish, before running the next?
View 5 Replies
View Related
Apr 21, 2010
I would like to know if is it necessary(and why) to use setsid to create a session leader in order to create a daemon process?
View 1 Replies
View Related
Mar 18, 2011
I am learning Linux daemon programming and write a simple daemon program. The issue is no data is written to the log file (/var/tmp/simpledeamon.log) though the file is successfully created (it's file size is zero from ls -l output). Could someone kindly point out the error in my program,The code is based on the Devin Watson's article at Here is the code:
// simplydaemon.cpp
// A simple Linux daemon.
#include <sys/types.h>
[code]...
View 2 Replies
View Related
May 10, 2010
I am working on a daemon that I want to change some variables while its running. Is this possible?I want to implement a command line type interface for my daemon so I can send it commands that will change the current values of specific variables, and also be able tell the daemon to load/save a config file.The only thing I have found so far is passing arguments to a daemon, but that seems to be a one-time shot when your first starting it.
View 6 Replies
View Related
Mar 8, 2010
Am not sure of the best way to go about writing a script. All I need at the moment is to start a java http server program at startup.How should I write languagetool.sh so as to be able to stop the script execution?
View 10 Replies
View Related
Jan 9, 2010
I would like to get the filename (without extension) and the extension separately. The best solution I found so far is:
Let FILE="thefilenameofsomefilesfor_instance.txt"
Code:
NAME=`echo "$FILE" | cut -d'.' -f1`
EXTENSION=`echo "$FILE" | cut -d'.' -f2`
I think it would be better to count the len and remove 3 chars to right to get the extension, but it can be macintosh filenames with have 4 chars for extensions.
View 5 Replies
View Related
Apr 2, 2011
i've written small tool in C which makes measurements on my router (OpenWrt White Russian).
It is working as a deamon. If the tool is started manually, everything works fine. If it is started per script on startup, the following system call doesn't work :
Code: sprintf(command,"/bin/cat /root/%s%s | /usr/bin/ssh -p2222 user(at)host -i /root/.ssh/id_rsa "/bin/cat >> result/%s%s"", apmac, source, apmac, dest);
rc = system (command); the returned rc in this case is 256.
first i thought it is a problems with the user rights for the tool, so i have added +s to it. but that didn't help. as i said, when the daemon is started by hand, the system call works fine.
View 1 Replies
View Related
Mar 8, 2010
know abt daemon process and how it is used for acting as proxy server if nay tutorial is there for it .
View 3 Replies
View Related
Jan 7, 2011
To create a daemon, you need to execute these 2 lines (among others):Code: init log
umask 0 What do each of these do?I didn't find anything on the 1st line. (The queries returned mostly "the log of the init (process)".)Google cast some light on the 2nd line: By setting the umask to 0, we will have full access to the files generated by the daemon. Even if you aren't planning on using any files, it is a good idea to set the umask here anyway, just in case you will be accessing files on the filesystem.
View 2 Replies
View Related
Mar 31, 2011
I need to rename the resulted searched files from a loopI have the following code:
find . -name DOC* | while read i
do
find $i -type f -name '*.txt'
done
basically, I am searching for all txt files inside any folder starting with DOC name.this code is working fine with me.I need to rename those .txt files to .txtOLDOS: Ubuntu 10.4Bash shell
View 10 Replies
View Related
Jan 29, 2011
I am trying to write a bash script that sources another bash script. Essentially, I need a few lines to check to see if a certain variable is set. If not, I set it manually, and then source a scripts with that variable in the path. I wrote a test script to try it, but for some reason the last line does not work. Here is what I wrote:
#!/bin/sh
source ~setupdir/setup.shrc #just a test, this line works
echo ${#SETUP} # prints 0 if setup is not set, which it isn't
if [ ${#SETUP} -eq 0 ]
then
SETUP="~setupdir"
fi
echo $SETUP # prints ~setupdir
[Code]...
View 5 Replies
View Related
Aug 24, 2009
One - where is the setting so when I click into a file it opens in the same Window instead of a new one?
Two - how can I toggle the side bar on and off like Ubuntu/SUSE nautilus have?
View 3 Replies
View Related
Jun 2, 2011
Now that nVidia is up and running, I'm curious to do a comparison with Nouveau. I there an EASY way to do this? Like a simple on/off switch? Major system/kernel changes are not an acceptable option. If it can't be easily done, I'll just stick with nVidia.
View 4 Replies
View Related
Apr 29, 2010
how do I toggle between breadcrumbs and location bar? Ctrl L just doesn't do anything, just gives focus to the already existing location bar.
I'd like breadcrumbs back.
View 6 Replies
View Related
May 5, 2010
I would like to toggle between 2 or more wallpapers on my 4 desktops (Compiz) with a simple hot key. Is there a command I can add to the Compiz command settings that toggles between 2 wallpapers?
View 8 Replies
View Related
May 8, 2010
I got rid of my bottom panel, but I am still used to 'Show Desktop' button right in the bottom left corner. I was just thinking is it possible to Toggle 'Show Desktop' state just by moving my mouse in that corner?I was thinking of using wmctrl and compiz commands edge biding, but my problem is that wmctrl has two different commands - one for showing desktop one for hiding. But I want to toggle.
View 4 Replies
View Related
May 11, 2011
I can't use function key combination to toggle between connected monitor and laptop monitor of my Dell N4010, running Ubuntu Natty.This happens in Unity interface only. In gnome (Ubuntu classic), function key combination works fine.When I press Fn+F1, it acts similar to pressing super+F1.
View 2 Replies
View Related
Jul 13, 2011
i'm in the process of learing C++. currently i'm creating shell scripts to get things done. i'm just curious how, as a programmer using C++ you would get a similar job done.as an example i have a script that takes the contents of files, pipes it to some sed and awk commands, which is piped to create a new file. that file is then imported into a mysql database.if you were going to do this in C++, would you call the sed/awk programs to modify the file, or can it be done within the program itself? i'm probably jumping the gun here because i've just started learing about pointers so this is above my ability
View 12 Replies
View Related
Jun 7, 2011
Is there a way to toggle between a gnome and KDE desktops?
View 9 Replies
View Related
Apr 4, 2011
I need a script/tool/whatever to toggle visibility of a specified window. I'm using Ubuntu with GNOME and compiz. I found wmctrl which can maximize, minimize windows and so on, but it couldn't make a window "hidden". There is even a option for it, but it doesn't work (neither for me nor for this guy creating this manual: [URL]
So my question: Is there another way to toggle visibility of a window? Any tool for that or even any commands for a bash script?
View 3 Replies
View Related
Apr 21, 2011
what is short cut key to toggle between pseudo terminals in red hat? how can i create customized short cut keys in red hat?
View 2 Replies
View Related