Which .bash does "do shell script" commands use?

The "do shell script" command uses the Bourne shell "sh". But I am curious to know which .bash it uses to define the shell environment variables.
I ran into a problem installing a third-party unix program which required new environment variables to be defined in order to execute. Defining these variables and executing this program from the terminal worked fine.
But executing it within a "do shell script" command in an Applescript - the program died silently because the environment variables it required were not defined in the shell Applescript uses. It appears to invoke a new shell which does not inherit the environment variables defined in your home user shell.
(I found this out by 'do shell script "set"' which listed the environment variables Applescript knows about - the ones I defined for the third-party program were not listed).
A "brute force" way of fixing this is to pass the environment variables directly:
do shell script "export THIRDPARTY_ENVVAR=blah; /usr/sbin/thirdpartyprogam"
This works but not exactly elegant, particularly when you need to pass a number of variables.
So - any better ways to do this? Can I edit the .bash Applescript uses, and where is it?
Thanks.

Another option that might work for you... if you are saving/distributing your AppleScript as an "Application bundler" is to group all your shell env. variables and other commands into a separate shell script file. Then include the shell script inside your app bundle. Locate the shell script at runtime and run that with "do shell script".
For example, create "myShellScript.sh"
#!/bin/sh
export THIRDPARTY_ENVVAR=blah
# ... more variable declarations..
/usr/sbin/thirdpartyprogam
# ... more shell commands...
Store the shell script file inside your AppleScript bundle's Contents -> Resources folder (remember to make the shell script executable). Then your AppleScript can find your shell script at runtime and execute it like this:
set ssPath to quoted form of POSIX path of (path to resource "myShellScript.sh")
set stdout to do shell script ssPath
Steve

Similar Messages

  • Wait for a "do shell script" command to finish

    i have an applescript that has to call a few external applications. i currently do this by setting the exact syntax of the external command in a string variable, then issue a "do shell script cmd" (seen many examples across the net using this standard)
    my applescript continues beyond these commands. how do i set the applescript to either wait for the above external command to finish, or not?
    regards
    jingo_man

    Usually AppleScript will wait for a shell script to complete before it continues, but adding an ampersand (&) at the end of the shell script command will make it run in the background, which allows the AppleScript to continue. See Technical Note 2065: do shell script in AppleScript for more information.

  • Shell scripts commands

    Hello.
    I'm having my first contact with Oracle Retail and I'm doing some shell scripts to extract/transform/load data.
    I was checking some scripts and I saw some commands as rmse_terminate, message, verifybinary, _call.
    Do you know where I can find some document explaining these commands and providing others if exist?
    Today I'm working with AIP, RDF and RMS.
    Let' me know if you can provide me a link or other path where I can find the document
    Thanks
    Edson

    Hi Ahmed,
    Can you please mention the names of the scripts where you found these calls, and the application to which those scripts belong to?
    Erik

  • Beginner question - testing for null string from shell script command

    I'm trying to test the result of a shell script command. I want to put out a message if the result is a null string. At present I get this applescript error "The command exited with a non-zero status"
    I'm sure this is a simple question ... but I can't figure out how to do it. Help!

    You can use try clause for the problem:
    set _result to ""
    try
    set _result to do shell script "/blah/andblah"
    end

  • Complex shell script command

    HI Experts
    can anybody know what this complex shell script command is doing .. i know its looking for some character at some point but exact explanation will be good for learning.
    egrep "^.{292}[CFOPRA][EPR]$" dn.dat
    Thanks

    A simple example can often demonstrate how things work:
    # cat sample.dat
    xABCDE1
    xABCDE2
    ABCDE3
    ABCDE4
    xDBCEA5
    xDBCEA6
    # egrep "^.A" sample.dat
    xABCDE1
    ABCDE4
    Above matches lines that begin with any character followed by an "A".
    # egrep "^.{2}A" sample.dat
    xABCDE2
    Above matches lines that begin with any 2 characters followed by an "A".
    # egrep "^.{2}[AD]" sample.dat
    xABCDE2
    xDBCEA6
    Above matches lines that begin with any 2 characters followed by an "A" or D".
    # egrep "^.{6}[345]$" sample.dat
    ABCDE4
    xDBCEA5
    Above matches any lines ending with "3", "4" or "5",
    provided it's the 7th character.
    # egrep "^.{5}[345]$" sample.dat
    ABCDE3
    Above matches any lines ending with "3", "4" or "5",
    provided it's the 6th character.
    # egrep "^.{6}[EA][26]$" sample.dat
    xABCDE2
    xDBCEA6
    Above matches any lines ending with combinations of "E2, E6, A2, A6",
    provided the combination starts at character position 7.
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • 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

  • Need to call Shell script that uses SQL loader in APex4.1/11g

    Hi there!
    I have a requirement, wherein I have to call a shell script that connects to an external server, ftp's a file in and then uses sqlloader to load data into our table. Now we have the ftp script that does this for another program, but is a scheduled job. I wanted to call the ftp shell script from within APEX. Any suggestions on how this can be done, what PL/SQL logic can we use? I see online some people using dbms scheduler for this?
    Thank you
    Sun

    Hi,
    Create some sh script on your oracle host machine where you can join into external server and run the process.
    something like:
    run_external_sh.sh
    #!/bin/sh
    ssh ext_user@ext_host ./sqlloader/import/import.shThen create a external JOB to call it via ORACLE(PL/SQL)
    -- Call Shell Script.
    BEGIN
      DBMS_SCHEDULER.create_program (
        program_name        => 'external_call_sh',
        program_type        => 'EXECUTABLE',
        program_action      => '/local_host/call_external/sh/run_external_sh.sh',
        number_of_arguments => 0,
        enabled             => TRUE,
        comments            => 'Call external SH script');
    END;
    /Now you can create a scheduled/or not scheduled JOB
    -- Job defined by an existing program and schedule.
    BEGIN
      DBMS_SCHEDULER.create_job (
        job_name      => 'jb_external_call_sh',
        program_name  => 'external_call_sh',
        schedule_name => 'external_call_scheduler', -- created scheduler
        enabled       => TRUE,
        comments      => 'Job defined by an existing external_call_sh program and schedule.');
    END;
    /Now you can call the JOB in APEX in PL/SQL process.
    BEGIN
      -- Run job synchronously.
      DBMS_SCHEDULER.run_job (job_name            => 'jb_external_call_sh');
    END;Regards
    J :D

  • Passing dialog text to a shell script command

    Hi. Newbie here. I got a good book, will learn this sooner or later.
    But right now, I got a problem I can't figure out
    I'd like to display a dialog box that requests some text. I'd then like to use that text as the variable for a shell commmand.
    Let's say for instance that I want to prompt for the asset tag number of the machine and want the result to end up in the ARD Info 1 field. I've got the first and third line, just don't know how to "place" the captured text:
    display dialog "What is this Mac's assett tag number?" default answer ""
    do shell script "defaults write /Library/Preferences/com.apple.RemoteDesktop Text1 <resultfrom_dialoghere>"
    Anyone?
    Darrin

    You use text returned of:
    dialog reply n : Reply record for the ‘display dialog’ command
    properties
    button returned (Unicode text, r/o) : name of button chosen (empty if ‘giving up after’ was supplied and dialog timed out)
    text returned (Unicode text, r/o) : text entered (present only if ‘default answer’ was supplied)
    gave up (boolean, r/o) : Did the dialog time out? (present only if ‘giving up after’ was supplied)
    ex:
    set _result to text returned of (display dialog "What is this Mac's assett tag number?" default answer "")
    do shell script "defaults write /Library/Preferences/com.apple.RemoteDesktop Text1 " & quoted form of _result

  • Automtor shell script "command not found"

    I want to include the execution of a shell script in Automator. The script just executes a third-party application (actually, pdftk) with certain parameters. I have written the script, saved it in my Home directory as "foo.sh", made it executable, and can correctly call it from Terminal with ./foo.sh. It works as expected.
    But if I include it in Automator's workflow, into action "Run shell script", its execution breaks complaining that "pdftk: command not found". This indicates that the script is correctly found and read by Automator. How is it, that Terminal's bash can find the command, but Automator doesn't ? Have commands to be written in a special way to be understood by Automator ? Perhaps third-party commands are not allowed in Automator ?

    As twtwtw has said, you environment when running Automator is NOT the same as when you are in a Terminal session.
    pwd:
    /Users/harris
    /bin/ls -dlaeO@ .
    drwxr-xr-x  349 harris  harris  - 11866 Mar 14 22:06 .
    id -a:  uid=501(harris)
    gid=501(harris)
    groups=501(harris),
    204(_developer),
    100(_lpoperator),
    98(_lpadmin),
    80(admin),
    61(localaccounts),
    12(everyone)
    $# 0
    printenv: SHELL=/bin/bash
    TMPDIR=/var/folders/zv/zvU6+bMiHTeElG+JIWOdzk+++TI/-Tmp-/
    Apple_PubSub_Socket_Render=/tmp/launch-rVMvHQ/Render
    USER=harris
    COMMAND_MODE=unix2003
    SSH_AUTH_SOCK=/tmp/launch-fH4Gt7/Listeners
    __CF_USER_TEXT_ENCODING=0x1F5:0:0
    PATH=/usr/bin:/bin:/usr/sbin:/sbin
    PWD=/Users/harris
    DBUS_LAUNCHD_SESSION_BUS_SOCKET=/tmp/launch-RIPIu6/unix_domain_listener
    SHLVL=1
    HOME=/Users/harris
    LOGNAME=harris
    DISPLAY=/tmp/launch-ttdbVO/org.x:0
    FRED=3-Mar-2009
    _=/usr/bin/printenv

  • Please help with executing the c-shell script by using the exe class

    I try to use the exec class to execute a c-shell script in my java gui program like this. But I don't get anything when clicking on the start button.
    here is my code:
    Runtime r = Runtime.getRuntime();
    r.exec("./DDMReportEvents");
    ./DDMReportEvents is the name of the c-shell script.

    I think Runtime.exec runs DOS batch files, but not Unix shell scripts.
    Try:
    r.exec("csh -c ./DDMReportEvents");
    to get the shell to run the shell script.

  • The Cave App. feels like early Mac games: Does anyone recall the commands used? Thank you.

    Greetings: I recall other early 90s games; however, the commands used to perform tasks is lost to me. Any help is of appreciation. Thank you.

    Wow they are ancient laptops! :) Both date back to around 1985-1988 and had the Intel 286 CPU with a mono/plasma screen.
    The best way to find information is to do a google search of the Model Number. You should see a PAxxxxx number on the Base Sticker
    computinghistory.org.uk also has some good info:
    http://www.computinghistory.org.uk/det/2235/Toshiba-T3100-20/

  • Re:Which port does the copy file function use?

    Hi ,
    How does the Copy File Function work?
    Which port is used?
    My problem is … When user copies the large request output file, the network is slow. So I want to manage bandwidth such as using Qos .
    Regards .

    Hi hussein ,
    Please find the details
    1)Please post the details of the application release, database version and OS .
    App Release: 11.5.10.2
    DB Version: 10.2.0.4
    IBM AIX on POWER Systems (32-bit)
    2)How does the Copy File Function work?
    What copy file function you are referring to? Please post the navigation path.
    1. Submit Request
    2. View Output File
    3. Tools --> Copy File
    3)Which port is used?
    My problem is … When user copies the large request output file, the network is slow. So I want to manage bandwidth such as using Qos .
    How are you planning to manage the bandwidth of specific port?
    If I know which port is used, I can manage it (give it to low priority)
    Regards .

  • Shell script Command Merge

    Can anyone help me to merge two commands into a single command
    1. cd ../../https-eportaldevw5/logs | cat pid
    2. ps -ef | grep $pid
    note-This $pid will be the output of command 1

    Thanks.. that was really helpful to me..
    one more question..
    when I am executing multiple commands one after another in a single go then one of the in-between command is not executed and skipped without execution.
    Example:
    echo "************************ SCC *****************************" > /tmp/output/op1.txt
    ps -ef | grep $(cat /opt/netscape/iPlanet/https-eportaldevw5/logs/pid) >> /tmp/output/op1.txt
    echo "****************** GLS ********************" >> /tmp/output/op1.txt
    ps -ef | grep $(cat /opt/netscape/iPlanet/https-eportaldevw3/logs/pid) >> /tmp/output/op1.txt
    echo "****************** TE Corporate ********************" >> /tmp/output/op1.txt
    ps -ef | grep $(cat /opt/netscape/iPlanet/https-eportalpoc/logs/pid) >> /tmp/output/op1.txt
    echo "****************** GCT ********************" >> /tmp/output/op1.txt
    ps -ef | grep $(cat /opt/netscape/iPlanet/https-eportaldevw1/logs/pid) >> /tmp/output/op1.txt
    echo "****************** eCommerce ********************" >> /tmp/output/op1.txt
    ps -ef | grep $(cat /opt/netscape/iPlanet/https-eportaldevw6/logs/pid) >> /tmp/output/op1.txt
    echo "****************** IMO ********************" >> /tmp/output/op1.txt
    ps -ef | grep $(cat /opt/netscape/iPlanet/https-eportaldevw7/logs/pid) >> /tmp/output/op1.txt
    echo "****************** ADR ********************" >> /tmp/output/op1.txt
    ps -ef | grep $(cat /opt/netscape/iPlanet/https-eportaldevw8/logs/pid) >> /tmp/output/op1.txt
    echo "****************** Corporate Trust Portal Server ********************" >> /tmp/output/op1.txt
    ps -ef | grep $(cat /opt/netscape/iPlanet/https-eportaldevw13/logs/pid) >> /tmp/output/op1.txt
    echo "****************** Corporate Trust App Server********************" >> /tmp/output/op1.txt
    ps -ef | grep $(cat /opt/netscape/iPlanet/https-eportaldevw14/logs/pid) >> /tmp/output/op1.txt
    echo "****************** GMW ********************" >> /tmp/output/op1.txt
    ps -ef | grep $(cat /opt/netscape/iPlanet/https-eportaldevw4/logs/pid) >> /tmp/output/op1.txt
    cat /tmp/output/op1.txt
    In above example,
    echo "****************** Corporate Trust App Server********************" >> /tmp/output/op1.txt
    this command is skipped when I am executing all commands in a signle go..
    Can anyone suggest me anything in this.

  • Trouble using Run Shell Script with python in Automator

    Hi. I have a python script I want to run in Automator (update_puzzles.py). All it does is check, rearrange and update files and there is not supposed to be any input. I can get the script to run outside of Automator, in Terminal, by navigating to the right directory and typing "python update_puzzles.py"
    I must not be setting up Run Shell Script correctly. I have it set to /bin/bash and Pass Input to stdin. The command line simply reads python /pathname/update_puzzles.py (where pathname is the path to the .py file, which I got by dragging the file onto the Run Shell Script command window). There are no actions before this in my workflow and the action after is View Results.
    The log says Run Shell Script failed, and the error is "Traceback (most recent call last):"
    Any suggestions?
    Thanks so much.

    If the script is expecting to do stuff with files in the same directory as the executable, you will probably need to add a statement to change to the appropriate working directory. The shell used in the Automator *Run Shell Script* action is a generic one that does not share any of the environment variables that the Terminal uses.

  • How does one run a shell script at system startup?

    Hi,
    I am trying to unmount my Boot Camp hard drive on my MacBook Pro. Now what I could do is create an automator action, save it as an application and then put it into my user´s login items. I am wondering though - shouldnt it be possible to run a simple shell script command like +diskutil unmount /Volumes/"Boot Camp"+ sometime during the startup process?
    Or to put it another way - is there an easy way to do this or do i have to create an manage a daemon through launchd ?
    Your help is very much appreciated.

    sorry I forgot to mention that there is a bug in Lingon which creates a plist incorrectly if you enter your script explicitly on line 2. At least I haven't been able to make it work. A workaround I always use it the following.
    Save your script as a *plain text* file from your favorite text editor. change the extension to .sh and make the file unix executable. Now, when you ccreate a launch daemon using Lingon, enter the path to that file instead of the script itself.
    This always works for me.
    Good luck!

Maybe you are looking for

  • Intellegent F4 help for contacts in Opp

    Hello All, We have the following issue and I hope to get answere from someone. In PCUI on Opportunities Partner Tab when we select contact person Partner Function and click on partner Input Help link it opens a BP search window and user can pick any

  • How to hide the list screen

    HI all, When i am calling another screen from my report program to display the result. I am Able to display the result on the intended screen but when i click  on back the back button it is returing to the list screen first and than next to the selec

  • I would like all links to open in the active tab, unless I command-click on the link.

    I've searched for answers to this question, and I was able to adjust the values for preferences in about:config so that all links open in the active tab, but after doing so I am unable to command-click to open a link in a new tab. Is there any way to

  • Filling Drop down in Adobe forms

    Hi experts,   I am developing a new Adobe form.In that I am using a table,the table consist of three drop downs in each row. My requirements are 1. I want to fill the three drop downs.Guide me in that.. 2. How to capture the value selected in first d

  • What's the difference in Apple RAID card battery error messages?

    I have a Mac Pro with 2 quad core Intel Harpertown CPUs at 3.2GHz, and an Apple RAID card.  RAID Utility shows that the battery failed but in my research, nobody explains the difference between "Battery failed (code 0x#0 = 17)" (which is what I have)