Small bash script as userspace daemon?

Hi!
I have a small bash script that I want to execute every 5 minutes. It's not vital, I'll notice if it stops working soon enough, so I'd like to get it out of my sight (both how it's started and when it's running - especially I don't want cron spamming the journal all the time. If it's convenient, I might try to pipe some assorted output to logger somehow, but that's not important). Now I'm trying to figure out how something like that is supposed to be done...:
I have questions like...:
- Should I modify the script so it has an infinite wait-5minutes-loop itself? And how do I make it break out of the loop if the service-handle-thingy tells it to / does it have to react to environment variables from something?
- Should I create a service file for systemd or what is supposed to handle such "pseudo userspace daemons"? While I found information on how to create the service files, I couldn't really figure out how the script behind it should look...
- Also I'm not sure if "daemons" should be executed as root and use sudo or something to do userspace stuff... or if the whole thing should be started as user.
I found only obsolete looking information on all of those things and examples that are specific to other distributions (saw lot of "start-stop-daemon" - I guess that's debian or something, not archlinux...?). So: Could someone please bump me into the general direction of the stuff I need to use / read?
Thanks!

whoops wrote:
Thanks!
Phew, that was a lot of stuff... browsed many examples too... and in the end it looks like the crontab was the "right" place to put that thing after all, everything else just seems like a "dirty" or overkill solution in comparison...
The only thing that still irritates me is cron insisting to write every single freaking *success* into the logs (/journal) instead of just warnings / errors. I really don't need that thing telling me: "Hi, I'm still OK! " every other minute -.- but there does not seem to be an option (other than installing a syslog-daemon capable of "blacklisting" the entries as a workaround) to shut it up... which was the reason why I first thought that scripts which are to be executes so often don't belong into the crontab.
Hmm... not sure what to do yet. Is there anything else I should know / read before I make up my mind and stop looking for a better solution to this?
Which cron do you use? I have dcron installed and it has a log level setting - see man crond

Similar Messages

  • Small Bash Script Problem

    I have this lovely little script that I whipped up:
    #!/bin/bash
    OIFS=$IFS
    for i in $( ls *.flv ); do
    set -- "$i"
    IFS="."
    declare -a Array=($*)
    if [ ! -e ${Array[0]}.mp3 ]; then
    ffmpeg -i ${Array[0]}.flv -vn -acodec copy -ar 44100 -ac 2 -ab 1048576 -f mp3 ${Array[0]}.mp3
    fi
    done
    IFS=$OIFS
    which looks for any .flv file that has no matching .mp3 file and creates that .mp3 file. It works fine but not for a .flv file with a space in the name.
    I tried
    ffmpeg -i \"${Array[0]}.flv\" -vn -acodec copy -ar 44100 -ac 2 -ab 1048576 -f mp3 \"${Array[0]}.mp3\"
    but that doesn't seem to work.
    Can anyone tell me how to get such files to process?

    Aha. I've had a long day -- I think I glanced at the if/then and didn't think it was necessary. Now that I look at it again, you're right to leave it in.
    You should probably assign the base filename to a variable rather than calling the string manip 3 times.
    Just an FYI: quotes in shell commands are for functional purposes only -- the actual quotes won't (and shouldn't) appear in the parsed command. If they did, the program executed would be looking for an argument that had a literal quote in it. Simply put:
    $ touch "foo bar"
    $ ls "foo bar"
    foo bar
    $ ls \"foo bar\"
    ls: cannot access "foo: No such file or directory
    ls: cannot access bar": No such file or directory
    Last edited by falconindy (2010-05-12 22:59:24)

  • Simple bash script to add a '-' [Solved]

    I need to write a small bash script to add a '-' to each line in a file before displaying via conky!
    Todo
    - Get Milk
    - Buy Food
    - Pay Bills
    Currently I use
    TEXT
    Todo
    ${hr}
    ${head /home/mrgreen/.stuffigottado.txt 30 20}
    In .conkyrc but have to add '-' each time I edit .stuffigottado.txt
    Thanks in advance....

    Cerebral wrote:
    To filter out blank lines, you could just modify the awk command:
    ${exec awk '!/^$/ { print "-", $_ }' stuffigottado.txt}
    very nice; awk and grep: two commands that never cease to amaze me.

  • Sending email using bash script

    Hello:
    I am working on writing a bash script to notify one or more users by email of certain events. Run from the Terminal command line, and having the script "echo" text of (what would be) a form letter with in-line variable expansion (i.e., ${VARIABLE}), all seems to work as anticipated. Eventually, I want cron to launch this shell script, and send an email to an "on-subnet" user (I have postfix enabled on my Mac, and there are multiple local user accounts).
    I found some stuff on the web about sending mail from bash scripts, and so I made a small little test script, that reads like this:
    #!/bin/bash
    VARIABLE[1]="The 12,345 quick brown foxes "
    VARIABLE[2]="jumped over the 67,890 lazy dogs."
    mail -s "a test email" jv << EOF
    This is a test:
    ${VARIABLE[1]}
    ${VARIABLE[2]}
    This is the last line of the test message.
    EOF
    echo "script completed"
    It worked... almost... It sent a local email to my postfix mail account that read like this:
    This is a test:
    The 12,345 quick brown foxes
    jumped over the 67,890 lazy dogs.
    This is the last line of the test message.
    EOF
    echo "script completed"
    So, I have two questions. First, the easy one (I hope):
    How do I delimit the end of the text, that I want to be the message body of the email, from portions of the script that follow said email text?
    Next question is a little more involved. You know how, in Mail.app, if you go to Mail Preferences>Accounts>Account Information, you can put multiple email addresses, comma-delimited, in the "Email Address" field? So, if a person entered "[email protected], [email protected], [email protected]" in this field, then, even though (s)he may be at home, and using their home ISP's mail server, (s)he could send an email apparently from either their home, work, or school email address. Of course, the mail headers clearly would show it came from and through their home machine and home ISP, but it would be displayed in the recipient's Mail client viewer as having come from one of [email protected], [email protected], or [email protected].
    I'd like to do something similar here, whereby the email (that is being sent to one or more local users' postfix account on my computer) would apparently be sent from "watchdog@localhost" rather than from "jv@localhost" like it seems to do by default. Whatever account the script is run from (or presumbably, whose cron tab is launching the script) is what the "From" address is set to.
    I'd rather not create an additional mail account, because I am using Mac OS X built-in accounts for the postfix mailboxes (I don't want to have to maintain a plaintext username:password file in postfix, and I don't want to create an additional user account on the computer).
    So, is there a way to specify an alternate "From" username when invoking the mail -s ${SUBJECT} ${RECIPIENT} command in a bash script? Or is there a different, alternate mail command that will let me do so? (please include a description of syntax and how I'd package the above message text for the alternate method).
    Thanks in advance, all!

    Hi j.v.,
    The > after EOF is just a typo (or may be added by the Discussion ?) and you must delete it; other > are prompts from the interactive shell. Andy's post shows an interactive use of shell, not a shell script (note the shell prompt % in front of the commands). A typical use of here document may look like
    command <<ENDOFDATA
    ENDOFDATA
    There must be no spaces before and after ENDOFDATA. The word ENDOFDATA can be EOF or any other string which is guaranteed not to appear in the text (the .... in the example above).
    You can modify the From: header by using sendmail command (postfix has it as a compatibility interface):
    /usr/sbin/sendmail -t <<EndOfMessage
    Subject: test mail
    To: jv
    From: watchdog
    This is a test:
    ${VARIABLE[1]}
    ${VARIABLE[2]}
    This is the last line of the test message.
    EndOfMessage
    There must be a blank line between the headers and the mail body.
    I assume that you send these mails only to users on your local Mac. Please do not send mails to remote users by using the sendmail command unless you know what you are doing completely.
    PowerMac G4   Mac OS X (10.4.5)  

  • /etc/rc.d/network: bash script: how to find out, if there was an error

    hello!
    i want to write a bash script for my wireless lan. for this i need the information, if the network daemon has connected successfully or failed.
    but there is a big problem: starting network success' every time, whether there was an error or not:
    $ /etc/rc.d/network start
    :: Starting network profile: 00wlan_home [BUSY]
    Error for wireless request "Set Mode" (8B06) :
    SET failed on device wlan0 ; No such device.
    [FAIL]
    :: Starting Network [DONE]
    $ ls /var/run/daemons/
    ... network ...
    can someone help me please? how can i realize  that "::Starting Network ..." also fails and the script returns an exit status 1?
    thanks for your help, maybe we can improve the script. but i'm not a geek in bash!
    mfg iggy

    iggy wrote:
    hello!
    i want to write a bash script for my wireless lan. for this i need the information, if the network daemon has connected successfully or failed.
    but there is a big problem: starting network success' every time, whether there was an error or not:
    $ /etc/rc.d/network start
    :: Starting network profile: 00wlan_home [BUSY]
    Error for wireless request "Set Mode" (8B06) :
    SET failed on device wlan0 ; No such device.
    [FAIL]
    :: Starting Network [DONE]
    $ ls /var/run/daemons/
    ... network ...
    can someone help me please? how can i realize  that "::Starting Network ..." also fails and the script returns an exit status 1?
    thanks for your help, maybe we can improve the script. but i'm not a geek in bash!
    mfg iggy
    try using netcfg to start the wireless profile, that should keep you happy until the new network scripts are unleashed... which won't have this problem.
    James

  • Writing to mplayer's stdin from bash script.

    I was just fulling with some bash script in order to automate the listening of my favorite radio stations via mplayer and a bash script. Going through the mplayers manual I saw the option -slave.
    -slave
    This option switches on slave mode. This is intended for use of MPlayer as a backend to other programs. Instead of intercepting keyboard events, MPlayer will read simplistic command lines from its stdin. The section SLAVE MODE PROTOCOL explains the syntax.
    At first I thought "ok, easy". I made some tries like "mplayer -slave -quiet .... < /tmp/stdin &" and then something like "echo -e 'mute' > /tmp/stdin" but it wouldn't work.
    Is it possible to send a process to the background inside a bash script and then write to it's stdin?
    SLAVE MODE PROTOCOL
    If the -slave option is given, playback is controlled by a line-based protocol. Each line must contain one command otherwise one of the following tokens:
    Commands
    seek <value> [type=<0/:1/:2>]
    Seek to some place in the movie. Type 0 is a relative seek of +/:- <value> seconds. Type 1 seek to <value> % in the movie. Type 2 is a seek to an absolute position of <value> seconds.
    audio_delay <value>
    Adjust the audio delay of value seconds
    quit
    Quit MPlayer
    pause
    Pause/:unpause the playback
    grap_frames
    Somebody know ?
    pt_step <value> [force=<value>]
    Go to next/:previous entry in the playtree.
    pt_up_step <value> [force=<value>]
    Like pt_step but it jumps to next/:previous in the parent list.
    alt_src_step <value>
    When more than one source is available it selects the next/:previous one (only supported by asx playlist).
    sub_delay <value> [abs=<value>]
    Adjust the subtitles delay of +/:- <value> seconds or set it to <value> seconds when abs is non zero.
    osd [level=<value>]
    Toggle osd mode or set it to level when level > 0.
    volume <dir>
    Increase/:decrease volume
    [contrast|brightness|hue|saturation] <-100-100> [abs=<value>]
    Set/:Adjust video parameters.
    frame_drop [type=<value>]
    Toggle/:Set frame dropping mode.
    sub_visibility
    Toggle subtitle visibility.
    sub_pos <value>
    Adjust subtitles position.
    vo_fullscreen
    Switch to fullscreen mode.
    tv_step_channel <dir>
    Select next/:previous tv channel.
    tv_step_norm
    Change TV norm.
    tv_step_chanlist
    Change channel list.
    gui_[loadsubtitle|about|play|stop]

    FIFO's are awesome and can be (ab)used for a lot of cool stuff.
    I've written some applications that do just what you are trying to do ( http://github.com/trapd00r/rmcd and http://github.com/trapd00r/RPD ), if you need inspiration.
    As for the backgrounding - you want to make a 'daemon', to detach from the running shell. See man fork, man 3 setsid and man 3 wait / man 3 waitpid (or my daemonize() function).

  • Ftp Download in bash script

    Hi! I'm runnig a bash script in solaris i want within the script to dowload file using ftp
    How can i do it?
    Tanks a lot

    For my driver download/reboot script I use a small program available in the ncftp package off of SunFreeware called ncftpget. It's takes a URL containing username, password, hostname, and path as the commandline argument and gets the file.
    ftp://ftp.sunfreeware.com/pub/freeware/sparc/8/ncftp-3.0.1-sol8-sparc-local.gz
    Hope that helps....
    -M

  • Bash script for checking link status

    So I'm doing some SEO work I've been tasked with checking a couple hundred thousand back links for quality.  I found myself spending a lot of time navigating to sites that no longer existed.  I figured I would make a bash script that checks if the links are active first.  The problem is my script is slower than evolution.  I'm no bash guru or anything so I figured maybe I would see if there are some optimizations you folks can think of.  Here is what I am working with:
    #!/bin/bash
    while read line
    do
    #pull page source and grep for domain
    curl -s "$line" | grep "example.com"
    if [[ $? -eq 0 ]]
    then
    echo \"$line\",\"link active\" >> csv.csv else
    echo \"$line\",\"REMOVED\" >> csv.csv
    fi
    done < <(cat links.txt)
    Can you guys think of another way of doing this that might be quicker?  I realize the bottleneck is curl (as well as the speed of the remote server/dns servers) and that there isn't really a way around that.  Is there another tool or technique I could use within my script to speed up this process?
    I will still have to go through the active links one by one and analyze by hand but I don't think there is a good way of doing this programmatically that wouldn't consume more time than doing it by hand (if it's even possible).
    Thanks

    I know it's been awhile but I've found myself in need of this yet again.  I've modified Xyne's script a little to work a little more consistently with my data.  The problem I'm running into now is that urllib doesn't accept IRIs.  No surprise there I suppose as it's urllib and not irilib.  Does anyone know of any libraries that will convert an IRI to a URI?  Here is the code I am working with:
    #!/usr/bin/env python3
    from threading import Thread
    from queue import Queue
    from urllib.request import Request, urlopen
    from urllib.error import URLError
    import csv
    import sys
    import argparse
    parser = argparse.ArgumentParser(description='Check list of URLs for existence of link in html')
    parser.add_argument('-d','--domain', help='The domain you would like to search for a link to', required=True)
    parser.add_argument('-i','--input', help='Text file with list of URLs to check', required=True)
    parser.add_argument('-o','--output', help='Named of csv to output results to', required=True)
    parser.add_argument('-v','--verbose', help='Display URLs and statuses in the terminal', required=False, action='store_true')
    ARGS = vars(parser.parse_args())
    INFILE = ARGS['input']
    OUTFILE = ARGS['output']
    DOMAIN = ARGS['domain']
    REMOVED = 'REMOVED'
    EXISTS = 'EXISTS'
    NUMBER_OF_WORKERS = 50
    #Workers
    def worker(input_queue, output_queue):
    while True:
    url = input_queue.get()
    if url is None:
    input_queue.task_done()
    input_queue.put(None)
    break
    request = Request(url)
    try:
    response = urlopen(request)
    html = str(response.read())
    if DOMAIN in html:
    status = EXISTS
    else:
    status = REMOVED
    except URLError:
    status = REMOVED
    output_queue.put((url, status))
    input_queue.task_done()
    #Queues
    input_queue = Queue()
    output_queue = Queue()
    #Create threads
    for i in range(NUMBER_OF_WORKERS):
    t = Thread(target=worker, args=(input_queue, output_queue))
    t.daemon = True
    t.start()
    #Populate input queue
    number_of_urls = 0
    with open(INFILE, 'r') as f:
    for line in f:
    input_queue.put(line.strip())
    number_of_urls += 1
    input_queue.put(None)
    #Write URL and Status to csv file
    with open(OUTFILE, 'a') as f:
    c = csv.writer(f, delimiter=',', quotechar='"')
    for i in range(number_of_urls):
    url, status = output_queue.get()
    if ARGS['verbose']:
    print('{}\n {}'.format(url, status))
    c.writerow((url, status))
    output_queue.task_done()
    input_queue.get()
    input_queue.task_done()
    input_queue.join()
    output_queue.join()
    The problem seems to be when I use urlopen
    response = urlopen(request)
    with a URL like http://www.rafo.co.il/בר-פאלי-p1
    urlopen fails with an error like this:
    Exception in thread Thread-19:
    Traceback (most recent call last):
    File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/threading.py", line 639, in _bootstrap_inner
    self.run()
    File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/threading.py", line 596, in run
    self._target(*self._args, **self._kwargs)
    File "./linkcheck.py", line 35, in worker
    response = urlopen(request)
    File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib/request.py", line 160, in urlopen
    return opener.open(url, data, timeout)
    File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib/request.py", line 473, in open
    response = self._open(req, data)
    File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib/request.py", line 491, in _open
    '_open', req)
    File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib/request.py", line 451, in _call_chain
    result = func(*args)
    File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib/request.py", line 1272, in http_open
    return self.do_open(http.client.HTTPConnection, req)
    File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/urllib/request.py", line 1252, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
    File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/http/client.py", line 1049, in request
    self._send_request(method, url, body, headers)
    File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/http/client.py", line 1077, in _send_request
    self.putrequest(method, url, **skips)
    File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/http/client.py", line 941, in putrequest
    self._output(request.encode('ascii'))
    UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-8: ordinal not in range(128)
    I'm not too familiar with how character encoding works so I'm not sure where to start.  What would be a quick and dirty way (if one exists) to get URLs like this to play nicely with python's urlopen?

  • Running java in Bash script

    Hi all,
    I need to run a bash script in Linux which will then run a java program. I managed to run the script successfully (and running the java program eventually) by doing ./myScript. However, when my script is being called by some other programs, the java program doesn't run. I've check the classpath and path, seems everything is in place. I tried having this :
    java myjavaProg
    in myScript, it doesn't work.
    I also tried this, it doesn't work as well :
    java -classpath /usr/local/nagios/libexec myjavaProg
    Anyone has any idea why? Thanks in advance.

    I'd suggest editing your bash script, replacing the java call with one that invokes a class with a clearer sense of what it's doing. I mean, write a small class that creates a file in /tmp or something, so you can be more sure whether or not it's being invoked.
    Perhaps your java program is running, but it's behaving differently in these circumstances.

  • Can you run a bash script on boot in single user mode

    Hey guys quick question.
    Is it possible to run a bash script on boot in single user mode.
    I can create a file and dump it on the root hd.
    Let's call it repair.
    I can then boot to single user mode and run it by typing /repair.
    But I want it to do it automatically.
    Every time I go into my machines that I clean for my job. I have to run sbin/fsck -fy
    Then I have to mount the drive and then remove all cache files, then reboot the machines.
    I would like to automate this by just holding command s and then moving to the next computer.
    There must be some sort of boot daemon somewhere.
    Please help.
    Sincerely,
    John

    Have you seen Applejack?
    http://applejack.sourceforge.net/
    It doesn't start automtically, but does cleanup.
    Robert

  • Escaping filename in bash script

    What is the easiest way to escape a file name in a bash script? Any legal character can be in the name.
    bash code:
    fileCheckSum=$( cat "${theFilePath}" "${theFilePath}/rsrc" | md5 )
    I thought that I escaped the filenames already. Guess not.
    /Users/mac/cons/see/file name varients/funies '2/file 4
    cat: /Users/mac/cons/see/file name varients/funies '2/file 4: No such file or directory
    cat: /Users/mac/cons/see/file name varients/funies '2/file 4/rsrc: No such file or directory
    Robert

    For my driver download/reboot script I use a small program available in the ncftp package off of SunFreeware called ncftpget. It's takes a URL containing username, password, hostname, and path as the commandline argument and gets the file.
    ftp://ftp.sunfreeware.com/pub/freeware/sparc/8/ncftp-3.0.1-sol8-sparc-local.gz
    Hope that helps....
    -M

  • Spinach (bash script)

    Hello,
    The other day I was talking in the IRC channel and mentioned a little script I wrote to download packages from the AUR. Somebody wondered how I would update packages... I hadn't thought that far into the future. However, now I have. I whipped up a little bash script. It does only the basics, but I was wondering if somebody could check it over and see if I'm doing anything horrendous. Sorry, the tabbing is messed up in a few places.
    Script: http://floft.net/uploads/spinach/spinach (also in the AUR)
    Description: http://floft.net/wiki/Scripts.html
    As for the name, I was going to name it "tower" since it's amazingly similar to "cower," but I didn't want to cause any confusion. Thus, I named it after a wonderful food.
    Note: The goal was to see how small I could make a functional AUR helper... I know there's a lot of perfectly good ones already.
    Garrett
    Last edited by Floft (2012-06-28 17:44:30)

    Odd that you would use both curl and wget. curl proves to be far more useful in the long run, doing everything that wget does (and more). Neat idea though. I've toyed with minimalist bash-based AUR helpers, as well as wrapping cower.

  • [SOLVED] Bash scripts to mount & unmount optical drive in Worker?

    I'm running XFCE on Arch with the HAL daemon being called in /etc/rc.conf.
    I can access media on my optical drive (DVD's or CD's) through the desktop icon that appears after HAL has recognised the drive, VLC automatically does its thing as does NeroLinux.
    The reason I'm posting is that I found a great DOpus clone yesterday called Worker - http://www.boomerangsworld.de/cms/worker/index?lang=en, which I am in the process of configuring.
    A problem I have is being able to access the optical drive via Worker.
    The way it is on my system, with HAL handling it, the first line (see below) appears after HAL mounts the media, which basically makes the two lines below it useless:
    /media/<title of disk>
    /media/cd
    /media/dvd
    I have tried configuring Worker to use /media/dvd (or cd), to access the optical media, these don't work for the reason stated above, & /dev/sd0 doesn't work either.
    So, do I have to turn off HAL, uncomment the lines in fstab & use mount?
    A little bash script, that would do the job for me would be great, as Worker will accept a script or a command string.
    I am a bash baby, so if someone can see a solution please post it?
    All input welcome.
    Thanks.
    Last edited by handy (2008-11-19 04:11:02)

    Zariel wrote:
    i guess something like this?
    %optical ALL=(ALL) NOPASSWD: ALL
    I found the clues for this in the sudoers manual:
    handy   ALL = NOPASSWD: /sbin/umount /CDROM,\
                    /sbin/mount -o nosuid\,nodev /dev/cd0a /CDROM
    Which works in so far as now mounting no longer needs the password.
    Which leaves me with the problem of trying to understand how to get Worker to mount the optical drive on command.
    If I enter the bash command in the Terminal as follows:
    mount /mnt/dvd
    the media is mounted, after which I can push the button in Worker, which I have configured with:
    /mnt/dvd
    & the root list of the optical media is displayed in the active panel of Worker.
    I just haven't been able to get Worker to use "mount /mnt/dvd" yet, there will be a way, I wonder how long it will take me to find it? lol
    Last edited by handy (2008-11-19 06:48:09)

  • [solved] Running a command in background (bash script)

    Salut,
    as netcfg2 does not work with my wireless connection, I have to set up the connection manually. For not having to type in the commands every time, I created a bash script.
    #!/bin/bash
    iwconfig wlan0 mode managed essid mynetwork channel 6
    ifconfig wlan0 up
    wpa_supplicant -D wext -i wlan0 -c /etc/wpa_supplicant.conf -dddd &
    dhcpd wlan0
    This works fine till the wpa_supplicant line. wpa_supplicant is not started in the background (as I thought, the ampersand at the end of the line would.
    So how can I get wpa_supplicant run in the background?
    Thanks in advance,
    Stefan
    Last edited by vbtricks (2008-05-11 09:13:36)

    Ramses de Norre wrote:How do you know it isn't? What exactly does happen?
    The script does not return to the user-prompt. Is an ampersand at the end of the line the correct solution, or are you unsure yourself?
    bender02 wrote:On thing is that even if it starts, it does take it a couple of seconds to connect, so it's probably not very good to run dhcpcd right after wpa_supplicant. Another thing is that you probably have a typo up there, shouldn't it be 'dhcpcd' instead of 'dhcpd'?
    Well, as the wpa_supplication command is not really run in the background the script did never execute the dhcpcd command. After having solved the above, correcting the spell-mistake will be a smaller problem. Even calling the dhcpcd command myself would be no unworkable way, the open root-shell (as I have to use another as the one calling the script is blocked) is a far greater problem...

  • [SOLVED] problem with spaces and ls command in bash script

    I am going mad with a bash script I am trying to finish. The ls command is driving me mad with spaces in path names. This is the portion of my script that is giving me trouble:
    HOMEDIR="/home/panos/Web Site"
    for file in $(find "$HOMEDIR" -type f)
    do
    if [ "$(dateDiff -d $(ls -lh "$file" | awk '{ print $6 }') "$(date +%F)")" -gt 30 ];
    then echo -e "File $file is $(dateDiff -d $(ls -lh "$file" | awk '{ print $6 }') "$(date +%F)") old\r" >> /home/panos/scripts/temp;
    fi
    done
    The dateDiff() function is defined earlier and the script works fine when I change the HOMEDIR variable to a path where there are no spaces in directory and file names. I have isolated the problem to the ls command, so a simpler code sample that also doesn't work correctly with path names with spaces is this:
    #!/bin/bash
    HOMEDIR="/home/panos/test dir"
    for file in $(find "$HOMEDIR" -type f)
    do
    ls -lh "$file"
    done
    TIA
    Last edited by panosk (2009-11-08 21:55:31)

    oops, brain fart. *flushes with embarrassment*
    -- Edit --
    BTW, for this kind of thing, I usually do something like:
    find "$HOMEDIR" -type f | while read file ; do something with "$file" ; done
    Or put those in an array:
    IFS=$'\n' ; files=($(find "$HOMEDIR" -type f)) ; unset IFS
    for file in "${files[@]}" ; do something with "$file" ; done
    The later method is useful when elements of "${files[@]}" will be used multiple times across the script.
    Last edited by lolilolicon (2009-11-09 08:13:07)

Maybe you are looking for

  • How to restrict a user to change his/her account information?

    Hi, I want to restrict some users so they can't change their account information (password, name, homepage, etc.). Any clue? TIA

  • Personalization Issue in Task Summary Page

    My client is trying to add a new column in the Cost Details table in the Task Summary page (Under Project Performance Reporting in PJT) through personalization. They are on 11i.PA.RUP3 (Screen shot in the attachment). They have an extended VO which b

  • Variable not defined: '_MR' error when using sub template

    Hi, I am creating a check print report. When I had the check layout and the invoice layout on the same template it worked fine. But when I moved the check layout to a sub template then I started getting the error Variable not defined: '_MR' but I don

  • Mail flow configuration.

    Scenario: Company abc.com mail server is hosted by a 3rd party hosting company. (mail.abc.com) I deployed an exchange 2013 server in the company abc.com. Created users similar to the users in the 3rd party host. When i sent mail from my exchange serv

  • CS6 indesign & illustrator very slow in processing

    since i installed CS6, both illustrator and indesign work extremely slow when moving objects, fonts etc. the documents are not big, just one spread full of text and the programm takes too long to process the action. working in CS5.5 was always fine b