Running Bash scripts via /Library/LaunchDaemons

I have a .plist in /Library/LaunchDaemons that calls a Bash script that lives in /usr/bin.. ...
With the script, one if the things I am trying to do is copy a directory from a non-admin user account, and place it on the administrator desktop.. Something like :
cp -R /Users/myuser/theDirectoryIwant /Users/admin/Desktop
The above code runs fine from Termimal ( I do 'sudo' first '), but if I add the line to the script...nothing seems to happen..I know the script is running ( I have it set for every hour in the .plist file, and I can see output in the Console) ...since it will run code such as this just fine :
cd ~/Desktop
mkdir Test
I am guessing that anything called from usr/bin would not need 'sudo' in a shell script there since it is already running as root?

I would suggest that you test your launchd environment out by capturing the output from
date >/tmp/myscript.txt
pwd >>/tmp/myscript.txt
id >>/tmp/myscript.txt
printenv >>/tmp/myscript.txt
Now allow this to be run via your launchd .plist and then look at the output. That should tell you what your environment looks like when your .plist runs.

Similar Messages

  • Running Bash scripts from jsf

    Hey I was just wondering if anyone knows how to run a bash script (whatever.sh) from a jsf page.?? I have a whatever.sh on a tomcat server where my web ap is and I was trying just to run it? Any idea???

    Why do you want to do this operation in a JSF page?
    It is better to do it in a Java class and then call the class from the JSF/ JSP page - keep JSF/ JSP only for disply / view purposes.
    Searc on Google for "How to call unix shell script using Java" for answers.

  • How to run bash script using Calendar

    Hi folks.
    How can I run a bash script using Calendar?  I thought I had to park it in an AppleScript script which I could call, but that isn't really working.
    Any suggestions appreciated.
    Cheers

    Hi there.  Thanks for the reply.
    Some notes for the replies:
    - The shell script has no environment issues.  It's a straight mysqldump for a single database.
    - The AppleScript has the do shell script "path/to/script.sh" user name "root" password "wobblyhead" with administrator privileges
    - Calendar application can only recognize the .scptd and .scpt files, and not .app files.  Upon choosing my original .scpt file with the do shell script instruction, it just opens the file in AppleScript Editor. 
    So the file gets called, but for some reason, it just opens the file and won't run the file.  No options for choosing a format where it's actually run. 
    Not sure how to go about this. 
    Cheers

  • Running Calc Scripts via Workspace

    Currently users are given 'admin' access to Essbase. That way when they are in Workspace they can see and run calc scripts on their apps. Is there a more proper way to give users the ability to run a calc on their apps without giving them 'admin' access?

    We have the calc scripts that run for data loads and other automated processes. Some of these calc's which are just AGG's and Calc Dim's I guess could be BR's too, but then we would have duplicates......
    Thats the sorry reason :)

  • Run bash script other than from terminal?

    Hi,
    I have a small 2 line script that runs an application...I want to create an icon to double-click to run the 2 lines and start the app, so I don't have to open Terminal and type the 2 lines.
    I've used Automator to create an app to do this, but in the task bar I see "run shell script" and the rotating wheel-thingy the whole time the app is open.
    Is there any way to create a script/app to do this without having "run shell script" and the rotating wheel-thingy going on?
    Cheers,
    Nige

    Hmm, why does the word "Platypus" keep running through my head?
    Bob, I'm trying to do the same thing (create a .app to launch a unix application) and I also ran into the aesthetic issue of the spinning gear in the menu bar for the entire time the app was running. Since the unix app I'm running is a Usenet news reader, that spinning gear would be a long-term distraction. I'll check out Platypus, but I and probably the others in this thread are trying to learn how to do this stuff ourselves to further our OS X knowledge, not merely to solve this one problem.
    So with that being said, does anyone know if there's a way to create an Automator "Run Shell Script" action with that spinning gear in the menu bar suppressed? You know, besides using Platypus.

  • Run AS3 script via html codetag?

    From what I know, it is possible to add <a href="....">
    or <a href="mailto:..."> in order to set dynamically a
    specific substring of a text to do either navigation to other page,
    or open to e-mail client. But is it possible to do much more
    important things, by just calling an AS3-function?... I am talking
    about a hyperlink to AS3 script code, instead to email client /
    browser.
    I.e. I want to download dynamic text with the names of
    Authors of papers from a database, and parse them serial i.e.:
    Authors:
    Author1Name,
    Author2Name, ...,
    AuthorKName".
    When the user press on a name, to open a vector flash pop-up
    (MovieClip) as a data-card of the specific Author. This could be
    done if there was an Flash-HTML tag like <a
    fref="loadModule(1)">
    Author1Name</a>, which would run the
    loadModule(1) function of the parent MovieClip that contains
    the dynamic text.
    I know something like this doesn't exist (
    add it to wishlist for future versions! :) ), but is there
    any other way to do it, except from creating one Object per author
    with MouseEvent listeners and place them dynamically to correct x,y
    positions?...

    It's as you describe it, with one problem: the "button"
    position and size is dynamically text-depending and not known
    before the data parsed to screen.
    Example:
    Create a textField and add inside it a dynamic text like:
    "Bill Gates created Microsoft". If this text was static I could add
    2 transparency buttons (listening to: MouseEvent.CLICK), one over
    "Bill Gates" and one over "Microsoft", where the first would make
    visible a movieclip talking about Bill Gates, and the second would
    make visible one movieclip talking about Microsoft.
    But the text can come as: "Microsoft was created by Bill
    Gates", or "There is a company named Microsoft, which was created
    by Bill Gates", or "Windows is a software created by Microsoft.
    Bill Gates was the one that created Microsoft". Thus you can't have
    apriori knowledge on where to put the buttons. In more advanced
    examples, I might not know how many buttons I should place also
    (i.e. of authors - i don't know apriori how many authors a paper
    has).
    This is same as in case of hyperlink: We don't know where a
    hyperlink can be, thus we place a tag for every hyperlink into the
    text that defines that hyperlink position and action.
    The only way to overcome this problem (just though of it) is
    to create my own tag, and before parse the text to check for that
    tag. For every tag to find the starting coordinates of it's inside
    text on the parent movieclip (x,y) and the ending coordinates - and
    providing that they have the same y-coordinate (no line change), to
    create a transparent button at the specific area over the text.
    If this is the only way to do it (thus making my own
    pseudo-html tag inside flash),
    I must know if it is possible to take (x,y) coordinates (in
    pixels) of a letter (upperleft corner) in a dynamic textbox.
    kglad, do you know if this is possible and how to do it?... (It may
    need to open new thread for this)...

  • Run calc script via business rule

    Hello all,
    I have calc scripts and business rules in my hyperion essbase.
    one of the calc scripts e.g. aggregates some values.
    In the business rule i copied the code from the calc script and this business rule can be executed in the planning tool.
    Now, everytime when i change the code from the calc script, i have to change same things at the business rule.
    And now my question:
    Is it possible to start a calc script with the business rule?
    e.g. content of business rule: execute "calc_aggregate"
    Is there a command?
    Then it would save time and i only have to change the calc script and not both.
    Thanks for your efforts,
    Chris

    1) try to use essbase 9.3 with dataexport command in calc script (this version essbase is compatible with planning versions 9x and 4.1)
    2) you can write (or found in google) UDF function for run system command or (and) export data set
    3) you can run system command from Planning web and run CSC and RUL from essmsh
    ER

  • Running PHP script via ColdFusion

    I'm running CFMX 7 on a Solaris platform with PHP 5.0.5.
    I need to determine the width and height of an uploaded image
    to ensure that the file can be reasonably used on a web page. I
    have scoured the Internet and found a numer of solutions to this.
    Most need the installation of additional software on our server and
    the creation of a custom tag. These are doable, but would require
    additional effort I don't have time for at the moment. Also, the
    software to install is a full image manipulation package that is
    definitely overkill for my needs. Kind of like threading a needle
    with a hammer.
    On the other hand I know that PHP has a command called
    "getimagesize" that would be perfect for my use. This would be much
    more simple and elegant. And I have created a small program (see
    below) that can accept a location of an image file and display the
    width and height of the image as a result. The code is:
    <?php
    list($width, $height) = getimagesize($argv[1]);
    echo "$width, $height";
    ?>
    I've tested it via the command line and it works fine.
    However, I'm having difficulty in running it via the ColdFusion
    cfexecute tag. Here is that code:
    <cfsavecontent variable="imgsize">
    <cfexecute name="#phpfilelocation#"
    arguments="#imagelocation#"></cfexecute>
    </cfsavecontent>
    I get nothing back from this. I've also tried the cfhttp tag
    with similar results. It seems to me that the argument (the
    location of the image) is not being accepted by the PHP code for
    some reason.
    I've looked for a solution to this within this forum and via
    Google, etc. to no avail. There is apparently something about PHP
    or ColdFusion that is escaping me. Any help clarifying why this is
    not working and (hopefully) a workaround would be very much
    appreciated. Thank you.

    Maybe this will help:
    http://groups.google.com/group/alt.comp.lang.coldfusion/msg/af84ac7dfec0d09e?dq=&hl=en&lr= &ie=UTF-8&oe=UTF-8&rnum=8

  • Multiarchive RAR bash script (SOLVED)

    Dear Fellow Archies!
    I use the command
    rar a -w<working_folder> -m5 -v<max_volume_size> <archive_name> <target_file_or_folder>
    whenever I need to make a multiarchive rar file, because I have not yet found a GUI archive manager that does this.
    So, I've decided to write a simple bash script to make things easier.
    Here's the script:
    #!/bin/bash
    echo Please, enter the full path to the target file or folder [without the target itself]!
    read PATH
    echo Please, enter the target filename [with extension] or folder name!
    read TARGET
    echo Please, enter the desired archive name [without extension]!
    read DESTINATION
    echo Please, enter the desired volume size in KB!
    read SIZE
    rar a -w$PATH -m5 -v$SIZE $DESTINATION $TARGET
    Executing the last line of the code in terminal works without any hassle. When I run this entire script however, it doesn't.
    What needs to be changed for the script to work?
    RAR man page is HERE - CLICK, in case someone needs to take a look at something.
    Thank you and thank you,
    UFOKatarn
    Last edited by UFOKatarn (2012-05-03 07:38:28)

    Done! Working!
    Geniuz: Logout-login did it. How simple.
    Juster: I added "echo $PATH" to the script and ran it with "bash -x". And the output was the same as after the logout-login. Here it is, in case you are curious.
    /usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/core_perl:/opt/qt/bin
    Thank you all for your help guys :bow:.
    OFFTOPIC:
    All who intend to use Xfce launchers to run bash scripts: There are two options in the settings for each launcher: "Command" and "Working Directory". And when I had "Working Directory" filled with "/home/username/", the script didn't work. It worked perfectly after I blanked out the "Working Directory" option. Just so you know, in case someone doesn't .
    This has never happened to be before, but still, I guess it is better to do it with blank "Working Directory" and entering the entire path into the script in the "Command" field. It might be that Xfce launchers always stick to the "Working Directory", even though a script might tell them otherwise.
    Last edited by UFOKatarn (2012-05-03 07:38:05)

  • Executing PowerShell script via JAVA

    Hi,
    I have simple powershell script as below :
    # Filename: Hello.ps1
    Write-Host
    Write-Host 'Hello World!'
    Write-Host "Good-bye World! `n"
    # end of script
    I wish to run this script via JAVA by the below JAVA code -
    import java.io.*;
    public class PsJava {
    public static void main(String[] args)
    throws IOException{
            Runtime runtime = Runtime.getRuntime();
    String cmds = (String)
    "cmd /C powershell C:/Documents and Settings/vvenkata/My         Documents/Hello.ps1";
            Process proc = runtime.exec(cmds);
            proc.getOutputStream().close();
            InputStream inputstream = proc.getInputStream();
                InputStreamReader inputstreamreader =
    new InputStreamReader(inputstream);
                BufferedReader bufferedreader =
    new BufferedReader(inputstreamreader);
    String line;
    while ((line = bufferedreader.readLine()) != null) {
                System.out.println(line);          
    Thanks
    Now, why is that I am not able to see any print statements from Hello.ps1 ? Can anyone help me on this?

    Hi,
    I have place my powershell script in the 'C' directory. and i have changed my JAVA code as below, but it still doesn't give any output in my Eclipse Console.
    import java.io.*;
    public class PsJava {
    public static void main(String[] args)
    throws IOException{
            Runtime runtime = Runtime.getRuntime();
    String cmds = (String)
    "cmd /c powershell c:/Hello.ps1";
            Process proc = runtime.exec(cmds);
            proc.getOutputStream().close();
            InputStream inputstream = proc.getInputStream();
                InputStreamReader inputstreamreader =
    new InputStreamReader(inputstream);
                BufferedReader bufferedreader =
    new BufferedReader(inputstreamreader);
    String line;
    while ((line = bufferedreader.readLine()) != null) {
                System.out.println(line);          
    Please advice me on this. If I have to create a batch file, then can you let me know how do I do that?
    Thanks

  • Bash script run via cron not executing MYSQL command

    I have a bash script which is run from a cron,
    It is executing as I have it write to a log file which it does correctly.
    I am wanting the bash script to restore a mysqldump file.
    When I run the bash script manually the dump file gets loaded fine. But when I run it through the cron the mysql command appears to be ignored.
    The mysqldump file is 54MB and I have checked to make sure that MYSQL is included in the global users path in /etc/profile
    Does anyone know why this maybe??
    Here is the bash file
    #!/bin/bash
    date >> /home/user/crons/crons.log
    echo "Started loadbackup" >> /home/user/crons/crons.log
    cd /home/user
    dbuser=root
    dbpass=password
    dbname=databasename
    filename=backup
    mysql -hlocalhost -u"$dbuser" -p"$dbpass" "$dbname" < " >> /home/user/crons/crons.log
    My crontab looks like
    02 17 * * * /home/user/crons/loadbackup.sh
    Many thanks
    Richard

    Hi Richard,
    Have you tried redirecting the script output in the cron to see if an error is being reported?
    I.e.
    02 17 * * * /home/user/crons/loadbackup.sh > /tmp/loadbackup.log 2>&1

  • Cannot run scripts via GNOME applications menu

    I have a few posts in the applications menu, like "Android Notifier Desktop" and the commando runs a script: "/usr/share/android-notifier-desktop/run.sh".
    That doesnt work anymore, I have to run it via the terminal now. I think it happend when I upgraded to GNOME 2.32. What to do?

    Thanks for your help. Nothing happens when I click the serial number. But I looked in Library/Receipts and found an update for 10.4.9, so I assume that is what I am running. I am also having problems with other applications such as MS Word and I get a different error message that says "Application Launch Failure: The application "Word" could not be launched because of a shared library error: "1<Microsoft Word><CarbonLib><CFMPriv_CarbonCore>"" Any advice?

  • Bash script won't run "sudo reboot" under cron, but perfect manually

    Hi Archers,
    I've got a weird problem with a bash script I use to run pacman and mythtv updates once a week via cron which also reboots itself so that new mythtv and kernels packages become active. This script works likes a charm when I run it manually as user from the command line. But when cron runs it (also as user) it executes everything EXCEPT the last "sudo reboot" command at the end. Sudoers seems to be setup right as it works fine from the command line. I could run this particular script with cron as root but I'd prefer not to update under root with the --asroot command.
    Any ideas? It seems like the permissions running manually and with cron are different somehow.
    Many thanks!
    Last edited by wdirksen (2012-10-09 13:07:28)

    OK, I'm going to reconsider this based on all your advices, but I'm still curious about why the command doesn't execute with cron. Related to this, I also find it strange that some root commands work fine with sudo, while others only work within a true root environment
    DSpider wrote:Post your /etc/sudoers file.
    So here's my sudoers file:
    ## User privilege specification
    root ALL=(ALL) NOPASSWD: ALL
    mythtv ALL=(ALL) NOPASSWD: ALL
    . . . and this is the script:
    #!/bin/bash
    sudo pacman -Syyu --noconfirm
    /usr/share/mythtv/optimize_mythdb.pl
    /usr/share/mythtv/mythconverg_backup.pl --rotate 20
    mythtvname="mythtv-git-$(date +%Y%m%d)-1-x86_64.pkg.tar.xz"
    cd /home/mythtv/AUR/mythtv-git
    makepkg
    sudo pacman -U $mythtvname --noconfirm
    sudo reboot
    Anything stick out here?
    Last edited by wdirksen (2012-10-09 19:32:52)

  • IDCS5-win. Error while running a script from indesign(not via estk)

    Hi all,
    After running the script from indesign, I get following error
    ASSERT '(engine->getDebugFlags() & ScScript::kExtendedErrors) == ScScript::kExtendedErrors' in ..\..\..\source\components\script\javascript\JavaScriptRunner.cpp at line 412 failed.
    ..\..\..\source\components\script\javascript\JavaScriptRunner.cpp (412)
    any idea about this?
    The script runs fine when run from ES tool kit.
    Thanks

    Hi,
    My colleague found the problem. We were using extendables library and we still haven't figured out what was actually happening, but removing it solved the problem.

  • How to create script that run sudo-command, via automator?

    Hi
    I'd want to create script to automate one command I need quite often. I just can't get this to work.
    I'm not using english OS, but I think this is what I do. In automator I choose Utilities -> Run script
    Here's the script I try to run:
    sudo "/Library/Application Support/VMware Fusion/boot.sh --restart"
    I found some tip to do it like this:
    do shell script "sudo /Library/Application Support/VMware Fusion/boot.sh --restart password "pass" with administrator privileges
    Where pass is my admin password.
    This does not work, either.
    Could anybody help me on this?
    Thanks...
    Tomi Toivonen
    Message was edited by: Tomi

    This is not working. What's wrong?
    What's wrong is that the '--restart' is a parameter for boot.sh, and therefore needs to be included within the quotes.
    Additionally, the shell uses spaces to divide parameters, so the spaces in the command will make it appear as multiple commands - '/Library/Application', 'Support/VMware' and 'Fusion/boot.sh'. You need to escape them using a backslash:
    <pre class=command>do shell script "/Library/Application\ Support/VMware\ Fusion/boot.sh --restart" password "pass" with administrator privileges</pre>
    If it's outside of the quotes it would be interpreted as a parameter to 'do shell script' and it won't know what to do with that.

Maybe you are looking for

  • DVD's not working

    Hi ... I am having a compaq presario v3425au notebook. From yesterday onwards I have observed a peculiar issue in my lappie. Cd's are working fine but DVD's are not getting detected.. I tried with a new sony DVD also but of no use.... I tried differe

  • Reasons to get an iPad when I have an iPhone and Macbook?

    Hello all! I've been contemplating getting an iPad for awhile now. I already have an iPhone (4) and an older MacBook (a mid-2009 white one running OS 10.5.8), and I also have an Amazon Kindle (first generation). So what I'm wondering is...what does t

  • Dump error of t.codes MR51

    hello, I am getting the dump error of t.codes MR51, kindly let me know the errors and how to solve the same and oblige. thanks sujatha

  • How to Integrate XI with Peoplesoft using iWay Adapter

    hi Friends,         This is Sreeni. I want to use iWay adapter for integrate Peoplesoft with XI. can you please help me in this way.

  • Can someone help with some quick questions?

    If someone has the time it would really help if I had the answers to the following questions. I appreciate they may be obvious or mundane to some but I am trying to set up a network at a primary school. I've searched the forum for answers with no luc