BASH Script - Launch App with

I'm trying to write a simple BASH script that will laungh an program, but that program needs command line arguments.
When I put it in quotes it says it can't find the file, if I don't use quotes then it won't run the program with the command line arguments. How can I launch a program using a BASH script with command line arguments?
Thanks in advance

#!/bin/bash
/Users/name/Desktop/Directory/app -f configfile

Similar Messages

  • BASH - Launch App with arguments

    I'm trying to write a simple BASH script that will laungh an program, but that program needs command line arguments.
    When I put it in quotes it says it can't find the file, if I don't use quotes then it won't run the program with the command line arguments. How can I launch a program using a BASH script with command line arguments?
    Thanks in advance

    Wrong forum. Try https://discussions.apple.com/community/mac_os/mac_os_x_technologies#/?tagSet=10 48

  • Launch apps with oracle jre 7

    With Apple discontinuing support jre 7 on its mountain lion, i am trying to find a way to launch my mac apps with oracle jre7. There are two situations occuring to me.
    1. Oracle jre7 could be before hand installed and my app should be able to detect and launch
    2 Or Bundle the oracle jre 7 with my Mac app and get into lauching it on mountain lion without any issues.
    Is there a better way or apple providing support in this regards.
    Help appreciated.

    Thanks NickClark_uk,
      I am able to install the java 7, but the Mac app i am trying to launch is unable to detect the oracle jre 7 and works fine with app store jre's. So we may need to bundle the jre or modify our apps to detect the installed JRE.
    I was looking at what would be the better approach in order to have my Mac app run with oracle jre 7.
    Thanks

  • Error "cannot locate object' launching app with Web Start

    Hello,
    I receive the error shown below when launching a Java application and cannot figure out where to begin with debugging. It was developed under Netbeans 5.0.
    You can recreate the error by launching this application:
    http://www.mikenaglich.net/ztest17.jnlp
    Error text and JNLP file follow. I am really puzzled and would appreciate any help. Thanks.
    Mike
    Error Text
    ========
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    The system cannot locate the object specified. Error processing resource 'http://www.netbeans.org/jnlp/DTD/jnlp.dtd'.
    App JNLP File
    ===========
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc.//DTD JNLP 1.5//EN" "http://www.netbeans.org/jnlp/DTD/jnlp.dtd">
    <jnlp codebase="http://www.mikenaglich.net" href="ztest17.jnlp">
    <information>
    <title>ztest17</title>
    <vendor>Mike Naglich</vendor>
    <homepage href="www.mikenaglich.net"/>
    <description> </description>
    <icon href="default"/>
    <offline-allowed/>
    <shortcut online="true">
    <desktop/>
    </shortcut>
    </information>
    <resources>
    <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
    </resources>
    <resources>
    <jar download="eager" href="dist/ztest17.jar" main="false"/>
    </resources>
    <resources locale="" os="">
    <jar download="eager" href="dist/lib/swing-layout-1.0.1.jar" main="false" version=""/>
    </resources>
    <application-desc main-class="ztest17.Main"/>
    </jnlp>

    I receive the error shown below when launching a Java
    application and cannot figure out where to begin with
    debugging. There are a number of problems, potential problems,
    redundancies and illogicalities in that JNLP file.
    ...It was developed under Netbeans 5.0. Uh-Huh. I am coming to recognise those
    (damnable) NetBeans JNLP files.
    You can recreate the error I don't think I need to, your error output and JNLP
    file are quite instructive..
    ...by launching this
    application:
    http://www.mikenaglich.net/ztest17.jnlp
    Error text and JNLP file follow. I am really puzzled
    and would appreciate any help. Thanks.
    Error Text
    ========
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please
    correct the error and then click the Refresh button,
    or try again later.
    The system cannot locate the object specified. Error
    processing resource
    'http://www.netbeans.org/jnlp/DTD/jnlp.dtd'.
    1) Whenever you see a message from Java,
    JavaWS, or an application saying words the the
    effect of 'cannot find..', try checking the URL of the
    resource in a browser. If a browser comes
    up '404' (not found), then the Java tool or app.
    will be unable to access it either.
    That is the first and fundamental problem with that
    JNLP. The DOCTYPE element is not strictly needed
    in a JNLP, and I would recommend removing it entirely
    rather than try and hunt down any NetBeans DTD.
    With the way NB writes JNLP's, I would not trust
    a DTD written or controlled by them, in any case.
    App JNLP File
    ===========OK.. I recommend replacing the current JNLP
    with the one below, here is a summary of the
    changes I made..
    - removed DOCTYPE line with reference to '404' DTD
    - compacted resource elements, removing empty attributes
    - changed ztest17.jar to main='true'
    - removed redundant 'download="eager"' attributes as well
    as main="false" and version="" from swing-layout.. jar element
    - removed broken(?) <icon> element and empty <description>
    - changed homepage href to relative
    Some of them are guesses, but I'd give it a 90%+
    chance of working, if written like this.
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp codebase="http://www.mikenaglich.net" href="ztest17.jnlp">
    <information>
      <title>ztest17</title>
      <vendor>Mike Naglich</vendor>
      <homepage href="/"/>
      <offline-allowed/>
      <shortcut online="true">
        <desktop/>
      </shortcut>
    </information>
    <resources>
      <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
      <jar href="dist/ztest17.jar" main='true' />
      <jar href="dist/lib/swing-layout-1.0.1.jar" />
    </resources>
    <application-desc main-class="ztest17.Main"/>
    </jnlp> Note that a glance inside the ztest17.jar supports
    it contains a manifest file tat specifies the main class,
    so it might be possible to remove main='true'
    altogether - best not for the moment, though.

  • Bash scripting, check filetype with file command

    Hi community,
    I've got as homework to write a script which uses the command file to check if a file is really a text file, and if yes echo its name.
    I wrote the following
    #!/bin/bash
    for filetype in *
    do
    a= file $filetype | cut -f2 -d' '
    b="ASCII"
    if [ "$a"="$b" ]
    then
    echo "$filetype"
    fi
    done
    however, this does not work.
    It just echoes the filetype and all the filenames.
    directory
    Desktop
    Bourne-Again
    existe
    gzip
    kernel26-one-2.6.27-3-i686.pkg.tar.gz
    Bourne-Again
    list
    Bourne-Again
    pidof
    empty
    ps
    Bourne-Again
    realjpg
    Bourne-Again
    taille
    ASCII
    temp.txt
    directory
    themes
    Any ideas?
    Why is the filetype echoed, when I declare it as a variable?
    Why does the condition thing not work?
    Basically, what am I missing?

    thanks for the ressource.
    here's the link
    http://tldp.org/LDP/abs/html/
    Thanks also for the answers, they were really helpful.
    ok, I wanted to post another problem I had but while I was pasting my code in here I realised my mistake.

  • Launching apps with Applescript

    I'm like a drunk driver wheb it comes to Applescript.
    I use Final Cut Pro to edit video and have a time tracker program to keep track of the time I spend editing. Is there an Applescript that will launch the time program when I launch Final Cut Pro?
    thanks for the help.

    I am a bit crippled at the moment when writing scripts as my mac is currently in for repairs, so am using my parents windows pc.
    I believe there are a number of ways of attacking this problem. Either have a small program always open checking for final cut launch or have a small application that launches both your time tracking program and final cut.
    i prefer the second method as it free up systems resources (not much but i always prefer having as little open as possible in regards to background processes). SO i would use something like this:
    tell application "Time Tracker"
    activate
    tell application "Final Cut Pro"
    activate
    end
    end.
    I would save it as an application named so it where final cut pro is, and then always use this applciation to launch final cut pro.
    However if you launch final cut another way, for example open up a document file that launches final cut pro then this method will not work and the first method described would be a better way of achieveing this. However i am at best a confident novice in regards to applescript and being hindered by not having my mac to try it out on, i can only give pointers.
    I believe this will check every 5 seconds for an instance of final cut pro. You can make the time intveral shorter or longer if you wish. I think the option you want to save it as is called "always open" and then in system preferences - accounts - login items select the script.
    if process "Final Cut Pro" exsists then
    activate application "Time Tracker"
    delay 5
    end
    As i said before this may not work correctly and can only check when my iMac comes back from being repaired (new screen, logic board and psu, so basically replaced but inside the same case). I am sure someone else will step in and offer help in the mean time if i have got something wrong.

  • Launch App with Native Process

    Hi,
    I want to launch serproxy application (http://www.lspace.nildram.co.uk/freeware.html) using native process in adobe air. But it seems not working.
    Here is my code:
    protected function launchSerproxy():void{
        if(NativeProcess.isSupported){
         var serproxy:File = File.applicationDirectory;
         serproxy = serproxy.resolvePath("serproxy/serproxy.exe");
         var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
         nativeProcessStartupInfo.executable = serproxy;
         var process:NativeProcess = new NativeProcess();
         process.start(nativeProcessStartupInfo);
         // connect to the com port
         setTimeout(connect,1500,"127.0.0.1",5339);
    Flex did not return any error or problem on runtime. What should I do to have Adobe Air load and run serproxy? Thanks.

    I think you just missing the working directory.
    "nativeProcessStartupInfo.workingDirectory = File.applicationDirectory;"

  • Bash Scripting with Conky -- How to implement?

    Hey Folks, my first post here and I'm looking for a bit of help. I've created a bash script to work with conky in which its purpose is to change the color of the battery bar depending on current voltage.
    Here's the bash script:
    #!/bin/bash
    # Change Conky battery color depending on charge
    chrg=`cat /proc/acpi/battery/BAT1/state | grep "remaining capacity" |
    awk '{print $3 }'`
    echo $chrg
    if [ $chrg -lt "3499" ]; then
    ${color red}${battery_percent BAT1}% ${battery_bar 4 BAT1}
    elif [ "$chrg" -lt "5100"]; then
    ${color orange}${battery_percent BAT1}% ${battery_bar 4 BAT1}
    else ${color green}${battery_percent BAT1}% ${battery_bar 4 BAT1}
    fi
    Essentially what it is supposed to do is grab and store the "remaining capacity" and if its lower than a certain point it changes color. What I'm having trouble with is actually implementing the colors into conky. Right now all it is doing is printing the charge as you can see. Any help would be appreciated. Thanks!

    I had this issue, took me three days to solve. Using if_match, put all your if_matches in a line, with each option having its color of choice, then put the bar, or % at the end.  You will need to make sure it is in sequential order so the color will not overlap the color you want for the state in the if_match. I know this is an old thread, I will edit my post when I get on my netbook with the code.
    I found this thread on a google search for bash and conky usages.
    [edit] here was my solution for the if_match using the battery.
    ${if_match ${battery_percent BAT1} <= 49}${color0}${endif}${if_match ${battery_percent BAT1} <= 20}${color9}${endif}${if_match ${battery_percent BAT1} >= 50}${color4}${endif}${battery BAT1} ${alignr}${battery_bar 6,160 BAT1}
    I have my colors set yellow for 49% and below, red 20% and lower, and last green for 50% and higher. Essentially this will pick yellow for under 49% and the if_match for red under 20%, the red will override the yellow, this is why order is important.
    Remember this is all in one line, now there are cleaner ways of setting this up using lua. That is something I am still working on.
    Last edited by mrknify (2014-03-05 17:09:59)

  • Trying to close an app with a shell script which was launched by same app.

    This may be simple, but is confusing me. I have an app that executes a shell script at launch. The script is designed to check for the existence of files and if not found, I want to display a message and close the application. The problem seems to be that I can't close the app with the script, since the script was called by the app and the shell is tied up. Does that make sense? I can't close the app because the script/shell is still active. Any ideas?

    Just have the script output some value for the app to read and then quit. Once the app reads the value, it will wait for the script to quit (shouldn't take long, especially if the script isn't running anymore) and then, if the value is a flag to quit, quit.

  • ???? how to launch bash script in cron ????

    with help from people in this forum, I successfully debugged the syntax in a shell script I wrote (my syntactical faux pas had to do with sending a multi-line mail message from a bash script).
    I can manually launch my script from Terminal's command line, and it works perfectly (well, at least it does exactly what I told it to do:). I try to launch it via cron, and it doesn't appear to ever launch.
    In /var/cron/tabs/root, the pertinent line of text reads:
    00 22 * * * /usr/local/customShellScripts/script.sh
    so it is supposed to launch daily at 10PM.
    Other jobs listed in /var/cron/tabs/root do run, because I get emails to my postfix admin account saying that they do. However, none of those other jobs are shell scripts; they are stuff like:
    24 06 * * 5 /usr/sbin/diskutil verifyVolume /
    The directory listing for /var/cron/tabs/root reads:
    $ ls /var/cron/tabs
    total 4
    drwxr-xr-x 3 root wheel 102 Mar 25 18:53:28 2006 .
    drwxr-xr-x 3 root wheel 102 Mar 20 17:13:47 2005 ..
    -rw-r--r-- 1 root wheel 1040 Mar 31 20:28:10 2006 root
    The directory listing for script.sh reads:
    $ ls /usr/local/customShellScripts/
    total 24
    drwxr-xr-x 6 root wheel 204 Mar 31 18:31:27 2006 .
    drwxr-xr-x 11 root wheel 374 Mar 5 12:26:23 2006 ..
    -rw-r--r-- 1 root wheel 6148 Feb 4 14:13:22 2006 .DS_Store
    -rwxr-xr-x 1 root wheel 8058 Mar 31 20:27:50 2006 script.sh
    for debug, the first two lines of script.sh read:
    #!/bin/sh
    /usr/bin/touch /foo
    but the file /foo never gets created. I tried using just "touch /foo" and that didn't work either.
    Also, since the script has a lot of calls to "echo," "expr," "date," "cut," "awk," etc., if I ever get cron to execute the script past the shebang line, do I have to preface all those calls with their full path? Or can I do something like in the old /etc/crontab file, where they defined a path variable up front
    PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
    and the script will be smart enough to look in those directories for the appropriate executables?
    But, getting back to the first problem, I am obviously overlooking something very basic, which is not surprising since I'm self-taught (and I guess, Apple Unix Discussions forum taught) at this unix thing and shell scripting. So, can anybody bail me out here...again?
    2001 Quicksilver G4   Mac OS X (10.4.5)  

    Hey Reese
    You bailed me out, dude! Apparently, my difficulties stemmed from me trying to directly edit /var/cron/tabs/root with pico. Never seemed to bother the other stuff, but it did this time. I am totally inept with vi, the default editor for crontab -e, which is why I had cheated before, and directly edited the /var/cron/tabs/root, el.al., so I had to find out how to
    export EDITOR='pico'
    in my .bashrc
    After having done that, no problem, except for a latent programming logic bug that has reared its ugly head (my script is doing some date manipulation with today's and yesterday's date, and my script crashed and burned on the month change and with stuff related to single-digit date sequence numbers <10).
    But, hey, I learned how to reset my default editor, so as to make life easier for me when it comes time to dorking with crontab files, and I learned that when the crontab file says "DO NOT EDIT THIS FILE - edit the master and reinstall," it means it!
    Thanx for the troubleshooting hint.

  • Bash script with sqlplus

    Hi, I hope I am in correct forum. I'm sorry, if not.
    I have following issue:
    #!/bin/bash
    ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
    ORACLE_SID=orcl
    PATH=$ORACLE_HOME/bin
    export ORACLE_HOME ORACLE_SID PATH
    sqlplus -s usera/oracle << EOF
    whenever sqlerror exit sql.sqlcode
    set serveroutput on feedback off
    -- some piece of code
    accept continue CHAR prompt 'To continue press ENTER'
    -- some piece of code
    exit;
    EOF
    I want to stop on line of accept command and wait for user input, but the code continues and doesn't wait for input.
    Is it possible to do this?

    It doesn't work because the sqlplus command is already taking its input from the "here" document (ending with EOF marker in your example). Once the "accept continue" line gets executed by sqlplus, the very next line of the "here" document satisfies the prompt.
    Try this instead:
    #!/bin/bash
    ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
    ORACLE_SID=orcl
    PATH=$ORACLE_HOME/bin
    export ORACLE_HOME ORACLE_SID PATH
    cat <<EOF > /tmp/sqlplus_script_text.$$.sql    ## the $$ is the current process ID, to prevent two running scripts from stepping on each other
    whenever sqlerror exit sql.sqlcode
    set serveroutput on feedback off
    -- some piece of code
    accept continue CHAR prompt 'To continue press ENTER'
    -- some piece of code
    exit;
    EOF
    sqlplus -s usera/oracle @/tmp/sqlplus_script_text.$$.sql
    rm -f /tmp/sqlplus_script_text.$$.sql

  • [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)

  • I upgraded my new iPad (iPad 3) to IOS 6 and everything went well except Siri won't launch apps. When asked say "launch Facebook" Siri responds with "it doesn't look like you have an app named Facebook" and I get the same results when trying to launch any

    I upgraded my new iPad (iPad 3) to IOS 6 and everything went well except Siri won’t launch apps. When asked say “launch Facebook” Siri responds with “it doesn’t look like you have an app named Facebook” and I get the same results when trying to launch any app. Siri works for everything else it just won’t launch apps. Any ideas? Thanks.

    I have this same problem... Seems like nobody else does. Siri won't launch any apps for me, including native apps.

  • Bash script to trim all filenames with special characters recursively?

    Hi,
    I have a 30 GB directory full of data I recovered from a friend's laptop after her Windows XP crashed. I'd like to burn that data, but I can't, because many of the filenames contain weird characters (spaces, accents, things even worse that my XTerm displays as inverted question marks). So, mkisofs exits with an error.
    I'd like to clean that mess up, but it would take months to do that manually. Well, I only know a very little Bash, but I think this problem is already too heavy for my modest knowledge. Here's the problem:
    - check the contents of directory ~/backup recursively
    - find files whose filenames contain characters other than [A-Za-z0-9] and then maybe "-" and "_" and ".".
    - replace these characters either by an "_" or just erase them
    Now how would I translate that into a little Bash script?
    Cheers...

    Heyyyyy... nice idea

  • Using SSL with client auth from a JNLP-launched app

    We have an application that is launched by JNLP, and which needs to make a mutually authenticated SSL connection to a server. The client cert and trusted certs that it needs to do this are stored in the Sun\Java\Deployment\security directory where JNLP knows to look for them. And Java WebStart itself seems to be able to use these certs just fine. However, our app seems blithely unaware of the location of the keystore/truststore unless we explicitly set the system properties javax.net.ssl.keystore and truststore. But we don't want to do that (it could be different for different users), and we shouldn't have to do that. So the question is, how can we use the same KeyManager/TrustManager that Java WebStart itself is using? Are they somehow available for the JNLP-launched app to use?
    Failing that, is there a way for a JNLP-launched app to query the deployment properties? There are a bunch of properties to direct the behavior of Java WebStart (see [http://java.sun.com/j2se/1.5.0/docs/guide/deployment/deployment-guide/properties.html]), such as deployment.user.security.trusted.cacerts. These don't seem to be System properties. Can the app see them, or are the "private" to Java WebStart itself?

    HI:
    see also shine enterprise pattern.
    I have worked with it and it helps me and results spead up.
    it has a class which is named "code" and does encryption and ... by md5. it is incredibly secure! tey it.
    you can download it via links bellow:
    http://groups.google.com/group/j2sos.
    http://sourceforge.net/projects/shine-enterpris/
    it has also document

Maybe you are looking for