Shell scripts and buttons

i cannot figure out how to get a button made in interface builder/xcode to run/execute a simple shell script. how do i do it. say i made a regular push button named button and i wanted it to start the "fivemin" shell script i pasted in below. assume the shell script is in my path already, do i need to export the path again as well.
also, my version of xcode is missing the shell script automator fron the new products options, is this a new thing.
but i would rather do it in a cocoa app. please give me an example say with a timed loop so i can check to see the process running via ps
###name: fivemin
#!/bin/bash
# this shell script simply sleeps in $incr second intervals for
# five minutes
trap 'echo "fivemin: EXITING"' EXIT
typeset -i nsecs=5*60 i=0 incr=4
while [ $i -lt $nsecs ]; do
sleep $incr
((i+=incr))
done
exit 0

To wrap a unix tool you need to use NSTask. Here's a useful tutorial from CocoaDevCentral.
If you're new to Cocoa as you say (in your other post), then I'd first recommend working through a couple of the basic tutorials knocking around to get an idea of the language and the tools available. Apple's own venerable 'Currency Converter' tutorial is here. MacDevCenter's also got quite a few here. You'll be able to find others on the web.
My version of Xcode (2.1) has a 'Shell Script Automator Action' in the new project assistant, 'Action' section. I've no idea if this has changed in the latest versions, nor why yours might be missing it. The template used when creating it is located in /Application Support/Apple/Developer Tools/Project Templates/Action/Shell Script Automator Action/.
Another solution that you might consider is using AppleScript Studio. This would use the 'do shell script' command from AppleScript and would use Interface Builder to create your window and button in a similar manner to a Cocoa version.

Similar Messages

  • SAP XI: How To Write Shell Script And use it in File Adapter On XI Server

    Hi,
    I want to split file at sender side in XI using Shell Script and then after i want to do
    Mapping.
    Can anyone tell me what exactly it means "write a script in UNIX shell on XI SERVER"?
    Regards,
    Akshay.

    Hi,
    You can execute a Unix script running in the XI server from the File communication channel. Ie. if you want to do something which was not part of XI adapter configuation , then you can make use of external unix script and you can execute those from the XI.
    For this, write a unix script and place in the XI OS level provided that path is accessible from PI Channel.
    E.g
    So u can use this in either Sender Channel to modify the data before it reaches into the Integration Server or in Receiver channel it is generally used to transfer the files into different location via Secure FTP
    SAP help: http://help.sap.com/saphelp_nw2004s/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm
    Blog:/people/sameer.shadab/blog/2005/09/21/executing-unix-shell-script-using-operating-system-command-in-xi
    XI  can be in any OS.
    Hope this helps,
    Rgds,
    Moorthy

  • Passing params from SQL file to Shell Script and then from Shell to SQL Fil

    Afternoon guys,
    Have a fun question for all you gurus in shell scripting out there. I have a shell script that is calling 2
    different SQL programs. My objective is to pass a variable called request_number from one sql program
    to the shell script and then from the shell script back to another SQL program. I will explain why I
    need this to happen.
    Here is what the shell script looks like which calls sql programs student_load_a.sql and
    student_load_b.sql. Student_load_a.sql basically creates the control file (.ctl) which is needed for the
    SQL*Loader and then student_load_b.sql reads the table that was just loaded and does the main
    processing. My main objective here is to be passing the request_number which is being generated
    using an Oracle Sequence in student_load_a.sql and using this generated number in my main
    processing in student_load_b.sql to select records from the table based on request_number.
    Any ideas ?Any help or recommendations is welcome and appreciated.
    *1. Shell Script*
    # Accept system input parameters
    p_user_id=$1
    p_job_id=$2
    # Create control files for sqlload
    sqlplus.exe -s $p_user_id @$STUDENT_PATH/student_load_a.sql $p_job_id
    exit_status=$?
    # Do sqlloads
    sdesqlldr.exe userid=$p_user_id control=student_load-$p_job_id.ctl \
                                                 log=student_load-$p_job_id.log \
                                                 bad=student_load-$p_job_id.bad
    exit_status=$?
    # Main processing
    # sqlplus.exe -s $p_user_id @$STUDENT_PATH/student_load_b.sql $p_user_id $p_job_id $p_request_number
    sqlplus.exe -s $p_user_id @$STUDENT_PATH/student_load_b.sql $p_user_id $p_job_id
    exit_status=$?
    exit 0*2. student_load_a.sql (Would like to pass back the Sequence Number back to shell script and then use in student_load_b.sql*
    -- Accept system input parameters
    define p_job_id = &1
    spool student_load-$p_job_id.ctl
    select
    'append into table TMP_STUDENT_LOAD
    FIELDS TERMINATED BY '','' optionally enclosed by ''"''
    trailing nullcols
    (request_number CONSTANT ' || '''' || request_number_seq.nextval || ''',
    student_id)'
    from   dual
    spool off;
    exit 0;
    {code}
    *3. student_load_b.sql (This is a big file so I am only adding code that is relevant for the SQL)*
    {code}
    declare
      v_request_number    number(6);
      v_student_id                  number(7);
      cursor cur_student_load is
        select  student_id
        from   TMP_STUDENT_LOAD
        where  request_number = v_request_number
        order by 1;
    begin
        v_user_id := '&1';
        v_job_id := &2;
        -- This is the variable I would like to be be passing from shell script to student_load_b.sql
        -- v_request_number = '&3';
         open  cur_student_load;
         fetch cur_student_load into v_student_id;
          exit when cur_student_load%notfound;
          .... more logic of if then else in here
         close cur_student_load;
    end;
    {code}
    Edited by: RDonASnowyDay on Jan 29, 2010 4:03 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    How come you are mixing WinDoze script (*.exe) with Unix?
    You are aware that you will be passing the password along with the user id to the second sql script?
    I will assume Unix ksh:
    # Accept system input parameters
    p_user_id=$1
    p_job_id=$2
    # Create control files for sqlload
    p_seqno=`sqlplus -s $p_user_id @$STUDENT_PATH/student_load_a.sql $p_job_id`
    exit_status=$?
    # Do sqlloads
    sqlldr userid=$p_user_id control=student_load-$p_job_id.ctl \
           log=student_load-$p_job_id.log \
           bad=student_load-$p_job_id.bad
    exit_status=$?
    # Main processing
    # sqlplus -s $p_user_id @$STUDENT_PATH/student_load_b.sql $p_user_id $p_job_id $p_request_number
    sqlplus -s $p_user_id @$STUDENT_PATH/student_load_b.sql \
               $p_user_id $p_job_id $p_seqno
    exit_status=$?
    exit 0And the first sql script would look like this:
    -- student_load_a.sql
    -- Accept system input parameters
    set echo off pages 0 feed off lin 80 trims on ver off
    def p_job_id = &1
    col seqno NEW_VALUE seqno
    select request_number_seq.nextval seqno from dual;
    set term off
    spool student_load-$p_job_id.ctl
    select
    'append into table TMP_STUDENT_LOAD
    FIELDS TERMINATED BY '','' optionally enclosed by ''"''
    trailing nullcols
    (request_number CONSTANT ''&&seqno'',
    student_id)'
    from   dual
    spool off;
    exit 0;
    {code}
    :p                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to run 3 job(a,b,c) parallel in unix shells script and after will complete d will start  and we have to handle the error also

    how to run 3 job(a,b,c) parallel in unix shells script and after will complete d will start  and we have to handle the error also

    032ee1bf-8007-4d76-930e-f77ec0dc7e54 wrote:
    how to run 3 job(a,b,c) parallel in unix shells script and after will complete d will start  and we have to handle the error also
    Please don't overwhelm us with so many details!  
    Just off the top of my head ... as a general approach ... something like
    nohup proca
    nohup procb
    nohup procc
    while (some condition checking that all three procs are still running ... maybe a ps -ef |grep  )
    do
    sleep 2
    done
    procd
    But, we'd really need to know what it is you are really trying to accomplish, instead of your pre-conceived solution.

  • Need help with shell scripting and Patching

    Hello all,
    I am a very new Oracle DBA and I just have an interview where i have been ask two questions that i have no idea of what it is
    1/ What is shell scripting and how do you do shell scripting?
    2/ What is Patching and how do you do patching?
    Can some one help to have a very good understanding of these tow questions?
    Thanks a lot

    1/ What is shell scripting and how do you do shell scripting?shell accept command from you (via keyboard) and execute them. But if you use command one by one (sequence of 'n' number of commands) , the you can store this sequence of command to text file and tell the shell to execute this text file instead of entering the commands. This is know as shell script.
    Shell script defined as:
    "Shell Script is series of command written in plain text file. Shell script is just like batch file in MS-DOS
    for example:- for taking backup, health check and doing some task Operating system level or Oracle database level we can create shell script and schedule a cron job
    2/ What is Patching and how do you do patching?for example ,in windows while using sometimes you might face an issue/error and it gives pop up error message would like to send/report this error to microsoft? microsoft will send you a fix for that. lot of fixes for errors/bugs are released as patches.( n number of patches with newer features are releases as new version)
    likewise in oracle for resolving bugs we should have to apply patch.
    patch is basically a fix for a bug/bugs. we need to use opatch utility to apply the paches.
    hope, this helps you

  • Autmator ruby shell script and regex to perform find and replace

    I am trying to create an automator workflow that uses a ruby shell script with regex to replace specified patterns in a text file.
    The following works fine to read (and return) the contents of the specified file:
    original=IO.read(ARGV.join,nil,2)
    changed=original
    puts changed
    However, if then use gsub to remove the word "BENEFICIARY", the action returns the text unchanged:
    original=IO.read(ARGV.join,nil,2)
    changed=original.gsub(/"BENEFICIARY"/,"")
    puts changed
    Using gsub! returns nothing at all.
    Any suggestions?

    This fails due the the spaces in the directory and app name
    Right, this is a common problem that many people encounter.
    I'm guessing I'm placing the single quotes or using the quoted form... improperly. Can someone please explain how to format a path in this manor.
    quoted form is the preferred/recommended way of doing this. Here's an example:
    set cmdPath to "/Users/just me/Desktop/Test Project/Test App.app/Contents/Resources/RWplist"
    do shell script (quoted form of cmdPath) & " --list"
    If you want to build the script manually then you should single-quote the entire path, e.g.:
    do shell script " '/Users/just me/Desktop/Test Project/Test App.app/Contents/Resources/RWplist' --list"
    Note that there are single quotes around the command path but the --list parameter is outside of the single-quoted path.

  • Shell script and escaped spaces

    Recently I decided I should do some backing up of my linux partition and the windows paritition so I decided to use dar with a little script to allow a full backup and a differential backup. The problem is that I have some directory names that have spaces in them and when the dar program is called from the script these become normal spaces and so it doesn't work.
    What should I do? I would rather write the script in ruby but that seems a bit excessive so it would be better to use a shell script.

    The latest issue of linux gazette will be of immense help to you. Sorry it is late where I am & I have to get some sleep. I think it is the answer gang, at the end of their section.
    linuxgazette.net
    There is also freshmeat, which has the latest bash tutorial & ref released within the last couple of days. abs-guide.html.tar.gz

  • Problems using Shell scripts and Automator

    My problem is that when I use the "Run Shell Script" Automator action, it won't work if I type the script inside the action but it will work if I just type a path to the script file, which is less elegant as I then need to copy the Automator app made as well as the script file.
    Here is the script I am trying to use
    #!/bin/bash -f
    if test -f ~/Library/Preferences/SPACE.com/Pro/Registration\ File
    then
    open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
    else
    ditto /Library/Management/Preferences/StarryNight/SPACE.com ~/Library/Preferences/SPACE.com
    open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
    fi
    exit 0

    Well I found the problem. Or at least I got it to work. I tried typing simple commands and scripts into the Shell Script action and had no issues with it running. So I then slowly expanded and typed out my script:
    #!/bin/bash -f
    if test -f ~/Library/Preferences/SPACE.com/Pro/Registration\ File
    then
    open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
    else
    ditto /Library/Management/Preferences/StarryNight/SPACE.com ~/Library/Preferences/SPACE.com
    open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
    fi
    exit 0
    Having typed it out in the script it runs fine. It seems you can't paste text into the action. To test this hypothesis, I copied the working script out of automator into BBedit and then back into Automator, the script no longer worked. Not sure why that is happening, but it does work if I type the scripts out.

  • Shell script and plsql

    Please guide me with parameter passing at 3 levels. Here is the scenario.
    a. A plsql-generateMaster.plsql- invokes stored procedure genMDetails(param1, query)
    b. A shell script genM.sh invokes generateMaster.plsql
    c. Need to pass date range as parameters (2 dates) to shell script.
    d. The shell scripts accepts the date range parameters and passes them to -generateMaster.plsql
    e. generteMaster.plsql uses the 2 date parameters to pass as part of query during the invocation of stored procedure genMDetails(param1, query)
    In short - shell script->plsql->stored procedure
    Platform is Sun Unix 8, oracle db 9i R2
    Thanks.

    This script shows how to pass parameters to PL/SQL anonymous block.
    sqlplus "mob/mob" << EOF
    set serveroutput on
    begin
    dbms_output.put_line('Parameter one: ' || '$1');
    dbms_output.put_line('Parameter two: ' || '$2');
    -- Here you can invoke procedure proc1(‘$1’,’$2’);
    end;
    EOF
    You can just invoke it like this:
    ./passParameters.sh 12-13-1981 03-04-2006
    Best Regards
    Krystian Zieja / mob

  • Shell script and keyboard shortcut

    I wrote a bash script, and I would like to start it with a keyboad shortcut, but I can't figure out how to do that. Does anyone know?

    Hi Hugo,
       Keyboard shortcuts are meant for Carbon and Cocoa applications but it can be done; you just have to wrap the shell script in some sort of application. One way is Sveinbjorn Thordarson's Platypus but I just wrap mine with an AppleScript, invoking it with "do shell script". You have to save the AppleScript as an application. Then you open the "Keyboard & Mouse" pane of "System Preferences" and select the "Keyboard Shortcuts" tab. Click the plus sign, '+', pick a key combination and specify your AppleScript or Platypus app as the target.
    Gary
    ~~~~
       Are there those in the land of the brave
       Who can tell me how I should behave
          When I am disgraced
          Because I erased
          A file I intended to save?

  • I need a 2 way sync tool for the mac (or a shell script and some help)

    I am looking for a way to (two way) sync a folder on my Macbook Pro with a SMB Server (aka Windows)
    I found a few paid for applications that do this, and before I buy one I thought I'd ask here and see if there are any recommendations.
    So far I've found Synk Standard and ChronoSync.
    I assume this could also be hacked together with Automator and some shell scripts, but I'm not sure how I'd do that.

    yes, Chronosync is often recommended for this kind of thing. Never heard of Synk Standard. you can also do it for free with rsync but I suggest you stick with Chronosync.

  • UDM and shell scripts and working with the ENVIRONMENT variable options

    In Userdefined metrics you have the ability to pass envronment variables.
    I was going to send
    DIR=/db/db05/oradata/ORCL/hot
    How to handle whats passed to the shell script?
    It passes $1 as {DIR=/db/db05/oradata/ORCL/hot}
    yes with the brackets. Here I figured it would simply set the DIR environment variable.
    Any cool tricks to work with this mess?
    Is it meant for perl scripts instead?
    Daryl.

    Ilmari Aalto wrote:
    Hi Darth,
    Thanks for your hint! Nevertheless I think it's something more profound, since there's no error etc. For example, should I have the path wrong I assume that OWB would return me some kind of an error when it doesn't find the .sh-file? Isn't there any log-file to see whether the command was executed? It seems like the execution of the User Defined element would be skipped altogether.
    Cheers,
    IlmariNo, if you don't give an absolute path OWB will not return any error, it just wont do anything at all...

  • Action Script and button Behavior

    Imported a bmp as png, made it into a movie clip. Setup the
    AS to call for page 4. It works great. I would now like to have a
    text box come up on the rollover. I tried to nest the mc into a
    button. I can make the text box work but the script won’t
    work when I click.
    Could you refer me to a resource that would explain the
    relationship between the two. Or is there another way to do this.
    So the text box says “Click here for more Info”.
    Can’t click to execute Action Script, I think it is not
    addressable because it’s nested in the button.
    If I reverse the nesting then the text box in the over frame
    won’t execute.

    Mjddoyle wrote:
    > Imported a bmp as png, made it into a movie clip. Setup
    the AS to call for page
    > 4. It works great. I would now like to have a text box
    come up on the rollover.
    > I tried to nest the mc into a button. I can make the
    text box work but the
    > script won?t work when I click.
    > Could you refer me to a resource that would explain the
    relationship between
    > the two. Or is there another way to do this.
    > So the text box says ?Click here for more Info?. Can?t
    click to execute Action
    > Script, I think it is not addressable because it?s
    nested in the button.
    > If I reverse the nesting then the text box in the over
    frame won?t execute.
    Sorry, a bit chaotic and i can't really get your arrangement.
    Please upload what you have so far, we will go from there.
    There is so many ways to achieve the same thing in flash that
    there
    is no point going into it, could turn up suggested solution
    totally
    does not suit your project. Need to see what you have so far.
    Upload to your server and provide URL for us to check.
    Best Regards
    Urami
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • Error in action script and button

    I have a page that i have designed for practice. i have three
    buttons on each page and have been tring to get them to link to the
    proper page/frame. For instance the button for ABOUT US should link
    to the second page/frame. The code i am using is as follows.
    on (release) {gotoAndStop(2);
    This should have it go to page/frame 2 and stop but when i
    test it it gives me this error.
    Scene 1, Layer 'about', Frame 1, ... 1087: Syntax error:
    extra characters fou... on (release) {gotoAndStop(2);
    I am using action script 1.0 & 2.0. I am not sure what to
    do.

    The way that this function is written, on (release), it
    should be
    directly attached to a button or movieClip instance. However,
    the
    gotoAndStop(2) command is telling the button or clip to go to
    frame 2,
    not the main timeline. If you change that line to
    _parent.gotoAndStop(2), you'll get the playback head on the
    main
    timeline to move, not the playback head in that button or
    clip.
    A far better method is to assign instance names to each
    button or
    movieClip that you want to react to actionscript. Then you
    can write the
    function(s) for those instance names. You would write the
    actionscript
    to a frame instead of directly on the button or clip. This
    makes the
    actionscript much easier to find when you need to edit.
    So, for instance, you could then write a set of functions to
    move the
    playback head. Something like this:
    // we'll assume that the buttons are named button1, button2,
    button3
    button1.onRelease = function() {
    gotoAndStop(X);
    button2.onRelease = function() {
    gotoAndStop(Y);
    button3.onRelease = function() {
    gotoAndStop(Z);
    // where X,Y and Z are the frame numbers that you want to
    move to
    // you don't need an explicit reference for the timeline for
    the
    playback head to use here. The code and the objects are all
    on the same
    timeline.

  • How to pass a variable to the shell script and crontab?

    Friends,
    here is my script.....
    exp userid=username/password@realdb file=/u02/logical_backup/abc_+$date+.dmp log=/u02/logical_backup/abc_+$date+.log owner=oraadmin statistics=none
    i want the exported file name as abc_2101.dmp and abc_2101.log (2101 is a date and month)
    I want to execute this script daily at 02:00 AM.
    so that i edited the crontab -e as....
    00 02 * * * ./u02/script/dailybkp.sh
    Now what i want is....
    1. is the steps are correct for crontab -e?
    2. Is the script of the crontab will execute daily at 02:00 AM?
    3. how can i rename the .log filename and .dmp file name daily according to the date. for example abc_2001 is today's date and month.how can i replace with the variable.
    thanks
    sathyguy

    sorry....i tested with cp command it was working fine...
    so, i thought it should work for exp command also.
    but its not working....also its not throwing any error....
    the crontab -e is having...
    00 02 * * * exp userid=system/password@realdb file=/u02/test/n22.dmp log=/u02/test/n22.log owner=scott statistics=none
    also i have tested by calling the script.
    #!/bin/bash
    00 02 * * * /u03/script/testbkp.sh
    its not working
    but the below one is working....
    00 02 * * * cp /u02/test.txt /u02/test/test.txt
    also this one is working....
    #!/bin/bash
    00 02 * * * /u03/script/testbkp.sh
    i listed the chkconfig --list crond
    crond 0,1,6 = off
    2,3,4,5 are on
    what might be the reason?
    thanks
    sathyguy

Maybe you are looking for

  • Apple ID password not recognized in io6

    Recently upgraded my new ipad 3rd gen to iO6 and can no longer access my account. Ever time I enter my password, another pop up would ask for it again. Despite the numerous attempts. Weird because I can sign and out under settings, but even while sig

  • 11.5.10.2 on windows7

    Hello , when i am accessing the 11.5.10.2 from client desktop windows7 64-bit, Oracle application does not display properly. The application is not getting refreshed, for example when I enter my user name and password I do not see what I am typing. I

  • MM_XSLTransform error

    I was having problems pulling in a feed using David Power's book "Dreamweaver CS4 with CSS, Ajax, and PHP" using the Dreamweaver XSL transformation server behavior. I kept getting the message "Error opening http//www.myfeed.com" but it worked fine on

  • Why can't I rotate multiple points in puppet warp at the same time?

    You can rotate single points in puppet warp, and you can shift+click to select multiple points and move them at the same time but I see no way to rotate multiple points as one group using puppet warp.  This would be a very helpful feature I think sho

  • App Memory Status incorrect?

    When I connect my iPhone 4 to iTunes, it says I have 8gb of Apps. This seemed way too high, so I physically added it up on a calculator and I actually have less about 3.8gb of apps installed. So what is taking up the remaining 4.2gb?! I have synced m