Port AppleScript to bash shell script

Hi all,
I made this script with the help of Neil from these forums. The purpose of the scrip is so that my friend can set up a share point on his NAS which is simply full of links so that if people access the NAS (its full of music and movies) if the delete a link, the file stays where it is.
The issue he has now, is that when he make the links in MacOS, a Windows system will no follow them. Is there a way around this or should the script be ported to a bash script so that the links can be created internally on his BSD NAS.
Thanks for any help and suggestions.
set these_items to (choose file with prompt "Choose files to link:" with multiple selections allowed)
set link_folder to (choose folder with prompt "Choose folder to place links in:")
repeat with this_item in these_items
tell application "Finder" to reveal this_item
set this_path to the quoted form of the POSIX path of this_item
set shell_folder to the quoted form of the POSIX path of link_folder
do shell script "ln -s" & space & this_path & space & shell_folder
end repeat
end

Your issue is one of symlink support, so it won't matter how you create the symlinks.
First off, which version of Windows are you running?
Only later versions of Windows (Win7 and, I think Vista) support symlinks, so if you're using anything earlier it won't work.
Secondly, if you're pointing to a network volume then the target paths have to match, and that's likely to be a problem in cross-platform environments. That's because the symlink file really just contains the path to the target and your paths may be different on each OS.
For example, On your Mac the sharepoint might be mounted at /Volumes/server and your file might be at /path/file on that share.
So your symlink file will contain '/Volumes/server/path/file'
No Windows system is going to be able to follow that path since disks aren't mounted under /Volumes. You would either have to know that share's current mount point or use a Windows path of the form \\server\share\path\file but that latter form won't work on non-Windows systems.
So the short answer is that you probably have to create two sets of links, one for the Windows users and one for the Macs. There's no simple, universal, cross-platform symlink standard that will do what you want (at least that I'm aware of).

Similar Messages

  • Problem with running Bash shell scripts

    I am unable to run Bash shell scripts on the UNIX Terminal application.
    This is the transcript from the Terminal application.
    Zhi-Yang-Ongs-Computer:/Applications/MetaPost/metapost-1.102 zhiyangong$ ./test1.sh
    dyld: Symbol not found: _BC
    Referenced from: /usr/local/bin/bash
    Expected in: /usr/lib/libSystem.B.dylib
    Trace/BPT trap
    Zhi-Yang-Ongs-Computer:/Applications/MetaPost/metapost-1.102 zhiyangong$
    Is this a problem with the the default installation of the Bash shell? Can I install the Bash shell on my own? If so, how can I do that?
    Also, how can I get the dynamic linker, dyld, to refer to the symbol "_BC"? What does this symbol "_BC" refer to?

    This was in your posted output:
    /usr/local/bin/bash
    You are NOT running the default bash, you are trying to run a private copy.
    The default Mac OS X bash is located at
    /bin/bash
    Try the following:
    /bin/bash ./test1.sh
    Does that work?
    What is the first line of your script? Is it:
    #!/bin/bash
    Or maybe
    #!/usr/bin/env bash
    /usr/bin/env would find the first bash in PATH . I find this most useful for finding perl on different systems, but sh, ksh, bash, zsh, csh, tcsh are all generally found in /bin so I do not bother using /usr/bin/env
    And if you have
    #!/usr/local/bin/bash
    Then the person that wrote test1.sh choose to use something besides the default bash
    Or maybe this script was transferred from some system where you needed to put your own copy of bash in /usr/local/bin because the vendor does not distribute bash
    Then again, you have not showed us what is inside your script, so it is possible something in the script called something else which invoked the /usr/local/bin/bash
    If that is the case, then you might try:
    /bin/bash -x ./test1.sh
    which should show you the commands executed before it died.

  • Invoking a bash shell script from Java code

    Hi All
    I am trying to invoke a Bash shell script using java code. The arguments required are "source wmGenPatch <source dir> <destination dir> no_reverse.
    in the code I have specified the arguments considering the cannonical paths of the files as the code may run on Unix or windows platform.
    I am getting a error while invoking Runtime.getRuntime().exec(args). The error is as follows :
    "The Error Occurred is: CreateProcess: source D:\Package4.0\workspace\DiffEngineScripts\v4a02\wmGenPatch D:\Package4.0\workspace\fromImageFilesDir\ D:\Package4.0\workspace\toImageFilesDir\ no_reverse error=2"
    It seems that error=2 indicates that the 'file not found' exception. But i can see the directories referred to in the error at place in the workspace.
    Kindly advice.
    Thanks in advance.

    Hi All
    I am pretty new to invoking bash shell scripts from java and not sure if i am progressing in right direction.
    The piece of code tried by me is as follows
    try {
                   currentDir = f.getCanonicalPath();
              } catch (IOException e) {
              if (currentDir.contains("/")) {
                   separator = "/";
              } else {
                   separator = "\\";
              String args[] = new String[7];
              args[0] = "/bin/sh";
              args[1] = "-c";
              args[2] = "source";
              args[3] = currentDir + separator + "DiffEngineScripts" + separator
                        + "v4a02" + separator + "wmGenPatch";
              args[4] = sourceFileAdd;
              args[5] = destFileAdd;
              if (isReverseDeltaRequired) {
                   args[6] = "reverse";
              } else {
                   args[6] = "no_reverse";
              try {
                   Process xyz = Runtime.getRuntime().exec(args);                              
                   InputStream result = xyz.getInputStream();
                   InputStreamReader isr = new InputStreamReader(result);
                   BufferedReader br = new BufferedReader(isr);
                   String line = null;
                   while ( (line = br.readLine()) != null)
                        System.out.println(line);
                   int exitVal = xyz.waitFor();
                   System.out.println("Leaving Testrun.java");
              } catch (Throwable t) {
                   t.printStackTrace();               
    and on running the same i am getting Java.io.IOException with the stack trace
    java.io.IOException: CreateProcess: \bin\sh -c source D:\Package4.0\workspace\DiffEngineScripts\v4a02\wmGenPatch D:\Package4.0\workspace\fromImageFilesDir\ D:\Package4.0\workspace\toImageFilesDir\ no_reverse error=3
    kindly advice
    Thanks in advance

  • Bash shell script to exception when database has been shutdown

    Hi, I'm quite new in shell scripting. I created the below simple script to do a check on the database, it's a count so it works fine... if the database is there. Now I want to be able to catch if the database is or is not there, what I tried so far didn't work, can anybody please give me a hand with this?
    The shell script file "start_check.sh":
    #!/bin/bash
    # Set environmental variables
    . /home/oracle/env/usrdwh1.env
    TEMP_FILE=rwcnt
    runCheckQuery()
    # Run query and dump result into the TEMP_FILE
    sqlplus -s "/as sysdba" > /tmp/${TEMP_FILE} << EOF
    @/u02/reports/sql/start_check.sql
    EOF
    if [ $? -eq 0 ]
    then err_num=0
    else err_num=1
    fi
    ################ MAIN ####################
    runCheckQuery
    row_count=`cat /tmp/${TEMP_FILE}`
    if [ $err_num -eq 0 ]
    then
    # If no rows were found then send an email alert
    if [ $row_count -eq 0 ]; then
    echo 'No process found - Please investigate' | mailx -s "Daily check ALERT" [email protected]
    fi
    else
    # There was an error when trying to connect to the db. Need to report it
    echo 'Database connection error - Please investigate - Error Message: (' $row_count ')' | mailx -s "Daily check ALERT (Database connection error)" [email protected]
    fi
    # Remove the tmp file
    rm /tmp/${TEMP_FILE}
    The sql script file "start_check.sql":
    SET SERVEROUTPUT ON
    SET FEEDBACK OFF
    WHENEVER SQLERROR EXIT;
    DECLARE
    row_count NUMBER;
    BEGIN
    SELECT COUNT(*)
    INTO row_count
    FROM dw_ml_ba ml_ba
    WHERE sys_id = 'CCX'
    AND ml_ex_start_datetime > TRUNC(sysdate);
    DBMS_OUTPUT.PUT_LINE(row_count);
    END;
    EXIT
    Edited by: leocoppens on Jan 4, 2013 4:05 PM

    There may be a better, but here is a shell script that works:
    #!/bin/ksh
    # db_check.sh
    # Script used to check if one or all of the databases on
    # one server are available.
    # Parameter Description
    sid=$1    # Database SID or Keyword 'all'
    function check1db
    sid=$1    # Database SID
    ORAENV_ASK=NO
    . /usr/local/bin/oraenv "$sid"
    ORAENV_ASK=YES
    if [ $(ps -ef|grep "ora_smon_$sid"|grep -v grep|wc -l) -eq 0 ]
    then
      echo "%-Error, Database $sid is NOT available - Not started\n" >>${CHKLOG}
      return 1
    fi
    dbok=$(\
    sqlplus -s / <<!
    if [[ $(echo $dbok|cut -d' ' -f1 ) == 'ERROR:' ]]
    then
      echo "%-Error, Database $sid is NOT available - Started with errors\n" >>${CHKLOG}
      return 1
    else 
      echo "%-Info, Database $sid is available\n" >>${CHKLOG}
    fi
    return 0
    } # end function check1db
    # Set some environment variables:
    ORACFG=/etc               # Location of oratab
    ORALOG=$HOME/logs         # Location for result log
    EMAIL='[email protected]'  # E-mail to send alert
    sid=${sid:-'all'}
    echo "$0 Job started at: `date` "
    BDATE=$(date +%y%m%d)
    export CHKLOG=$ORALOG/db_check_${sid}_${BDATE}.log
    echo "$0 on `date`" >$CHKLOG
    if [ "$sid" = "all" ]
    then
      i=0
      stat=0
      cat $ORACFG/oratab | while read LINE
      do
        case $LINE in
         \#*)            ;;      #comment-line in oratab
            sid=`echo $LINE | awk -F: '{print $1}'`
            check1db "$sid"
            stat1=$?
            ((stat += $stat1)) # Combine the Status of All Calls
            ((i = $i + 1))     # Count Number of Databases Checked
        esac
      done
      ((j = $i - $stat))  # Count Number of Databases Available
      echo "\n%-Info, `date +%c`,\n\tTotal databases checked = $i,\n\tAvailable = $j, Not available = $stat\n" >>${CHKLOG}
    else
      check1db $sid
      stat=$?
    fi
    # Beep operator if database down.
    if [ ${stat} -ne 0 ]
    then
      SUBJ="Database(s) alert."
      mailx -s"$SUBJ" $EMAIL <$CHKLOG
    fi
    echo "$0 Job stoped at: `date` "
    exit $stat:p

  • AppleScript syntax do shell scripts

    Hi guys,
    i am having endless issues with the syntax of the following applescript. Please help me and i'll make you my new god, cheers. The
    applescript syntax is:
    tell application "Finder"
      display dialog ¬
                        "Select Output Source" buttons {"Computer", "TV"} default button "TV"
              set InternalSpeakers to (do shell script "cd ~/Downloads/SwitchAudioSource-v1; ./SwitchAudioSource -s 'Built-in Output'")
      --InternalSpeakers is now a variable which changes the sound output to Computer
              set HDMI to (do shell script "cd ~/Downloads/SwitchAudioSource-v1; ./SwitchAudioSource -s 'Soundflower (16ch)'")
      --InternalSpeakers is now a variable which changes the sound output to TV
              if button returned of result = "Computer" then InternalSpeakers
              if button returned of result = "Computer" then HDMI
    end tell
    at the moment i am getting the following error:
    I have tried arranging and re-arranging the applescript to no avail, please help me

    You're over complicating the situation. This
    set InternalSpeakers to (do shell script "cd ~/Downloads/SwitchAudioSource-v1; ./SwitchAudioSource -s 'Built-in Output'")
      --InternalSpeakers is now a variable which changes the sound output to Computer
    sets InternalSpeakers to what the do shell script returns. It does not set InternalSpeakers to hold the do shell script command to run when you access the variable. There are ways to do this but its not needed here. Just do thsi as a simple if then else
    display dialog ¬
                        "Select Output Source" buttons {"Computer", "TV"} default button "TV"
    if button returned of result = "Computer" then
         do shell script "cd ~/Downloads/SwitchAudioSource-v1; ./SwitchAudioSource -s 'Built-in Output'"
    else    if button returned of result = "TV" then
        do shell script "cd ~/Downloads/SwitchAudioSource-v1; ./SwitchAudioSource -s 'Soundflower (16ch)'"
    end if
    Something like this will work.  Also there is no reason for the code you show to do it in a tell block. The Finder isn;t needed for this.

  • Automator/Applescript not running shell script properly

    I can open Terminal, and this command works:
    lame -h --abr 256 /Users/myhome/Desktop/Some\ Wav\ File.wav /Users/myhome/Desktop/TheMP3.mp3
    But when I try to run the same command in applescript from Automator, it fails.
    set sourceFile to quoted form of POSIX path of "/Users/myhome/Desktop/Some Wav File.wav"
    set mp3File to quoted form of POSIX path of "/Users/myhome/Desktop/TheMP3.mp3"
    set command to "lame -h --abr 256 " & sourceFile & " " & mp3File
    display dialog command
    do shell script command
    The display dialog outputs:
    lame -h --abr 256 '/Users/myhome/Desktop/Some Wav File.wav' '/Users/myhome/Desktop/TheMP3.mp3'
    Which, as little as I know of applescript, is how applescript handles spaces in filesnames. Can anyone please help?

    You need *do shell script* attribute described in the 10.4 Changes section of http://developer.apple.com/mac/library/releasenotes/AppleScript/RN-AppleScript/R N-104/RN-10_4.html#//appleref/doc/uid/TP40000982-CH104-SW1 Additional info can be gained by posting to the AppleScript and Unix forums under OS X Technologies.

  • Invoking a Package.Procedure via bash shell script

    Hello All,
    I am using the below syntax to call package in a unix shell script, is this right way of calling and checking for errors or is there any other better approach?? kindly suggest.
    I am using Oracle 11g & Linux OS, SQL*Plus: Release 11.2.0.3.0 Production
       RETVAL=`sqlplus -s FCSDWH_STG/${DBSTG}@${DBSRC} <<EOF
            EXEC FCSDWH_STG.FCA_HASH_TOTALS_PKG.HASH_TOTALS_COMPUTE(${PROVIDER},${UNINUM},${EXTRACT_DT},${VER_NUM});
            EOF`
            if [ `echo ${RETVAL} | egrep "ERROR"` ]
            then
                    logit "Error While Generating The SQLPLUS Output File, Please Check"
                    exit 1
            else
                    logit "SQLPLUS Output File Has Been Generated Successfully"
            fiThanks much.

    Ariean wrote:
    I am testing the same above functionality with the below sample procedure, and I am purposefully making it compile erroneous with "dbms_output.put_lin" just for sake of testing.
    create or replace
    procedure today_is as
    begin
    dbms_output.put_lin('Today is : ' || to_char(sysdate,'DL'));
    end today_is;This is sample shell script "test.sh" I am using
    #!/bin/bash
    RETVAL=`sqlplus -s FCSDWH_STG/FCSDWH_STG@dwdev <<EOF
    set termout off
    exec today_is;
    EOF`
    echo "start here"
    echo ${RETVAL}
    echo "end here"
    if [ `echo "$RETVAL" | grep "ERROR"` ]
    then
    echo "Error While Generating The SQLPLUS Output File, Please Check"
    exit 1
    else
    echo "SQLPLUS Output File Has Been Generated Successfully"
    fiBelow is my output
    start here
    BEGIN today_is; END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00905: object FCSDWH_STG.TODAY_IS is invalid
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    end here
    /home/infrmtca/bin/test.sh: line 8: [: too many arguments
    SQLPLUS Output File Has Been Generated SuccessfullyI don't understand why it is printing "SQLPLUS Output File Has Been Generated Successfully" though it errored out.Because statements within backquotes are executed before the statement calling the backquote. The [ command has too many arguments coming from the echo and grep.  You might put just that test part of the script in it's own little script and test it, it seems to say that whether there is an ERROR in $RETVAL or not.  You might need to man test and see if you need a -z argument or something.
    >
    Edited by: Ariean on May 15, 2013 10:08 AM
    Edited by: Ariean on May 15, 2013 10:16 AM

  • Starting Java Program with a bash Shell script

    Hi !
    I know this is a Linux query but I am putting it on this site to get different answers.
    I want to start my Java program with a shell script. Can anybody give me a proper script to start my Java program?
    I am using RH Linux 7.3 and JDK 1.4.
    Can I start the Java program without starting the terminal? Just like the Sun One Studio4 'runide.sh' script.
    Please help.
    Bye Niteen

    assuming you have your PATH and CLASSPATH variables set correctly, your script should look like this:
    #!/bin/bash
    cd <project_dir>
    java <class> &
    example:
    #!/bin/bash
    cd ~/projects
    java project1.main_package.MainClass &
    of course you could add some more elaborated stuff like compiling files before running the program, etc.
    if you dont like terminals, try running "nautilus" (it's like Windows Explorer). i never use nautilus (especially for running scripts), so i cant guarantee it will work, although i dont see why it shouldnt...

  • Bash shell scripting

    Dear Mac Users:
    I have a bash script which I copied from a bash book to learn how to use bash. Whenever I try to run it on Linux (cygwin--Windows Linux interpreter) it throws an error that something is wrong with the syntax.
    But when I try to run the same script on my Mac using Terminal.app the bash shell throws an error saying access denied. I chowned a copy of bash and referenced this copy in my script but I still get the error. I also chowned the script to the user account on my Mac. Why can I not run the script?

    #!/bin/bash
    # cookbook filename: mkalbum
    # makalbum - make an html "album" of a pile of photo files
    # ver 2.0
    # An album is a directory of html pages.
    # It will be created in the current directory
    # An album page is the html to display one photo,with
    # a title that is the filename of the photo, along with
    # hyperlinks to the first, previous, next, and last photos.
    # ERROUT
    ERROUT()
    printf "%b" "$@"
    } >&2
    # USAGE
    USAGE()
    ERROUT "usage: %s <newdir>
    " $(basename $0)
    # EMIT(thisph, startph, prevph, nextph, lastph)
    EMIT()
    THISPH="../$1"
    STRTPH="${2%.*}.html"
    PREVPH="${3%.*}.html"
    NEXTPH="${4%.*}.html"
    LASTPH="${5%.*}.html"
    if [ -z "$3" ]
    then
    PREVLINE='<TD> Prev </TD>'
    else
    PREVLINE='<TD> Prev </TD>'
    fi
    if [ -z "$4" ]
    then
    NEXTLINE='<TD> Next </TD>'
    else
    PREVLINE='<TD> Next </TD>'
    fi
    cat <<EOF
    <HTML>
    <HEAD><TITLE>$THISPH</TITLE></HEAD>
    <BODY>
    $THISPH
    <TABLE WIDTH = "25%">
    <TR>
    <TD> First </TD>
    $PREVLINE
    $NEXTLINE
    <TD> Last </TD>
    </TR>
    </TABLE>
    </BODY>
    </HTML>
    EOF
    if (($# !=1 ))
    then
    USAGE
    exit -1
    fi
    ALBUM="$1"
    if [ -d "${ALBUM}"]
    then
    ERROUT "Directory [%s] already exists.
    " ${ALBUM}
    USAGE
    exit -2
    else
    mkdir "$ALBUM"
    fi
    cd "$ALBUM"
    PREV=""
    FIRST=""
    LAST="last"
    while read PHOTO
    do
    # prime the pump
    if [ -z "${CURRENT}" ]
    then
    CURRENT="$PHOTO"
    FIRST="$PHOTO"
    continue
    fi
    PHILE=$(basename "${CURRENT}")
    EMIT "$CURRENT" "$FIRST" "$PREV" "$PHOTO" "$LAST" > "${PHILE%.*}.html"
    #set up for next iteration
    PREV="$CURRENT"
    CURRENT="$PHOTO"
    done
    PHILE=$(basename ${CURRENT})
    EMIT "$CURRENT" "$FIRST" "$PREV" "" "$LAST" > "${PHILE%.*}.html"
    # make the symlink for "last"
    ln -s "${PHILE%.*}.html" ./last.html
    # make a link for index.html
    ln -s "${FIRST%.*}.html" ./index.html

  • How to embed applescript into a shell script for notification center

    I have managed to cobble this together:
    You can run it in your Terminal, it is harmless, and will output results that will show you a notification from notification center:
    I have items on my pasteboard as the results of a script, I want to pbpaste them into the below command, but can't get the syntax right.  I am not objectionable to string concatenation and building or whatever it takes.
    osascript -e 'display notification "The url(s) are on your clipboard from my.app" with title "my.app has finished" subtitle "Some Sub title"'
    Ideally, I want to put `pbpaste` in the "Some title" section, but I get the literal string. I try creating a variable, and get that literal string.
    I tried building the entire string up as one variable, which in the Terminal echo'd out and works, but in Notification Center, I get the actually literal variable.  It's mainly a bash script, so the context witch to AppleScript i being a pain in the rear.
    Suggestions? Any master out there that this makes any sense to?

    As it stands, and the way you have your notification structured, this is the output from the notification center. I did an echo "From the clipboard" | pbcopy before I ran the following script. It uses a Bash function, osascript HERE document, and shows how to pass variables to the function, and receive them in AppleScript. If you want substring text that is not the result of pbpaste, then you can either make the string inside the AppleScript, or pass the string in as a variable.
    To get this output, I used the following Bash/Osascript combination:
    #!/bin/bash
    #osascript -e 'display notification "The url(s) are on your clipboard from
    #my.app" with title "my.app has finished" subtitle "Some Sub title"'
    function notification () {
      `osascript <<-AppleScript
            set txt1 to "The URL(s) are on your clipboard from "
            set txt2 to " has finished"
        set appName to "$1" as text
        set subStr to "$2" as text
        set noteStr to txt1 & appName
        set titleStr to appName & txt2
        tell application "System Events"
            display notification noteStr with title titleStr subtitle subStr
            delay 1 -- give notification time to fire
        end tell
        return quit
    AppleScript`
    appName="foo.app"
    #echo $appName
    subTitle="$(pbpaste)"
    #echo $subTitle
    notification "${appName}" "${subTitle}"
    exit 0

  • Bash shell scripting in Netware OS

    I've been trying to port a reporting script I had put together for out OES Linux servers to run in bash on the Netware OS servers. I've been having a few issues with bash thought, and was wondering if the issues I'm running into are just limitations of the OS, or if maybe it is handeled differently in the Netware OS implementation of bash.
    Also, another thing to note is I'm testing this on Netware 6.5 sp 8
    variables in scripts:
    ex. in linux this would work
    $variable = `df -h`
    echo $variable
    for some reason it appears that the variable is hanging up bash in netware and the command just fails.
    the other issue I've been having is if I want to string a few commands together with specific commands:
    ex:
    volumes |grep -i vol1
    this seems to hang up the whole server. I'm able to do this with other commands, but when I use volumes, I got an error " BASH: cannot duplicate fd 6 to fd 0: bad file number"
    this however isn't as big a deal as not being able to work with variables...
    has anyone else tried this that might be able to help?

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1
    > ex. in linux this would work $variable = `df -h`
    Um............. no, it wouldn't. First, you would not have a dollar
    sign at the beginning; second, no spaces around equals signs. Try the
    following:
    variable=`df -h`
    Better yet, try something really simple:
    variable=testvalue
    echo $variable
    Also keep in mind that some commands, I think volumes included, do not
    run normally within bash. If you want output from things like that you
    should probably get the contents to a file first and then grep against that.
    - From my own minimal experience with bash on NetWare also beware of
    processes that run forever (find, for example, on an entire large
    volume) as things like Ctrl+C do not seem to interrupt them well.
    It may help if you tell us what you're really trying to do. There may
    be better ways to pull this off.
    Good luck.
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v2.0.18 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
    iQIcBAEBAgAGBQJP7LfoAAoJEF+XTK08PnB5560P/314qw9tUXO5z/BVVhupV7kI
    ZzSi6u2JF6PeRIEPey0/O+jQ/i4aRs3AVWzmn+ykyk16JrFpqd4aJlOg3c0VBlYs
    /56p9u18cPbROJteF44HQC6YKwrBEjy39a4PK0cx4nTJbX9qcLz EQKst7VdvtTE5
    MeQJ3pifkOfMtKHEZPpagGyXC5vlTZpjj/CsQu8nwUb7TBlJ21o0OOhfY7P0G6HX
    E8o/qvCBTlP5PXQVfqIi+vwuYAb0pK7iUIHACwwd1P/cGSI7bA8Bp1oFz3auzwSh
    99RdGj7ZXlCjFKqpehuUE54R3b7+9njc+2eNxiaBp8jvWrn5ag 8VTQwG884zHE4n
    qW+p5tSdYbXe2LktorweTU9MhHZj/pLanE1ym8iSnk+6DTYZI8lQieLRs9LUJrlp
    cNFXh9Jxul/zGmdkoY89ddZHrDCHVRfUnsXmNDjfS5XqY55diCFKMYjM0BU5m rmC
    5tlk6EPSAFK/102e7pSpn4DWCw1WYhkwS68NuUIb/6oGHTJHo+GBCDfakLOHMhEd
    b/OvQX6EHRyo+w0Kj+DY1Ny4amViVYjy0Cahhv7L7lZ1hQTVuQBl CzNDSBuKH+8m
    sfdvTmrmHU/0j6ewtMvoB/RkLmebfhYMziFZRnahxYVJUXpejV2INzhEGC8wg84P
    I6tCX1NT0jvgP4FSf4Xv
    =Ux8a
    -----END PGP SIGNATURE-----

  • Executing a unix kill from APEX or running a bash shell script from Apex

    I'm writing a browser based app that I would like to write with APEX and that will identify and kill a very specific process name and Unix user name combo.
    I can identify the unix PID in V$SESSION if I want so, I know how to to the first part (identify the process/PID).
    How can an APEX app execute the Linux kill command? I'm not seeing anyway to host out of APEX. I was looking for something like that where you create processes...
    Please provide only suggestions on how to do this from APEX. I know there are lots of other ways (CGI from Apache etc.).

    I have this working, though it's kinda clunky.
    Apex calls Oracle Stored Procedure which calls Java stored procedure which defines a class that runs exec to execute an OS command, and waits for the return value.
    The DBA had to grant special permission for my oracle schema to execute the script name that is passed into the Java.
    Others may have a better way of doing this.

  • Sqlplus and unix (bash) shell scripting

    Hi,
    I'm extracting some information from a DB and then "spooling" it to a file. So far so good.
    The problem is that the records I get are not like what they look like when I run the stuff in sqlplus. Instead, the spooled file has alot of weird spaces and tabs in between and does not properly separate between the different rows.
    Does anyone have any tips on how to do this?
    Note: The datatype of the field I'm retrieving is "long". I've set linesize, pagesize and long to 1000.

    Hi!
    Try also to change SQL*Plus settings, i.e. SET LINESIZE 1000 (or whatever the most long line of your report could be), then TRIMSPOOL ON, TRIMOUT ON.
    Regards,
    Andrew Velitchko
    BrainBench MVP for Developer/2000
    http://www.brainbench.com

  • AppleScript: How to let AppleScript use the same environment as Bash shell does?

    Howdy!
    I can run AppleScript from Bash shell.
    I can also run Bash shell from AppleScript.
    So my question is when I run a Bash shell script from AppleScript, I am hit with a path problem.
    Suppose my AppleScript is under ~user/a.scpt. I want my AppleScript to know its current path (i.e. ~user/a.scpt).
    So a quick snippet test in my AppleScript shows that AppleScript always begins from the root directory:
    do shell script "pwd"
    So let's do a workaround AppleScript like this:
    tell application "Finder" to set currentDir to (target of front Finder window) as text
    do shell script "cd " & (quoted form of POSIX path of currentDir) & "; pwd"
    This works. However, this approach poses a potential danger.
    Suppose when I run this AppleScript for a bash script, I inadvertently clicked other Finder Window. That would result in execution of bash script in that newly clicked Finder Window, resulting in a big mess.
    Is there a better way to let the AppleScript to know its current path?

    The following is what your Applescript environment looks like, so plan accordingly.  If you want your Applescripts to be portable to other user environments, you should NOT depend on your environment, but rather embed all the environment knowledge you need into your script.
    Applescript "do shell script" environment
    pwd:
    /bin/ls -dlaeO@ .
    drwxr-xr-x  36 root  wheel  - 1292 Feb 28 09:58 .
        /usr/bin/id -a
    uid=501(raharris)
    gid=20(staff)
    groups=20(staff),
    402(com.apple.sharepoint.group.1),
    12(everyone),
    61(localaccounts),
    79(_appserverusr),
    80(admin),
    81(_appserveradm),
    98(_lpadmin),
    403(com.apple.sharepoint.group.2),
    33(_appstore),
    100(_lpoperator),
    204(_developer),
    398(com.apple.access_screensharing),
    399(com.apple.access_ssh)
    $#
    0
    $0
    /path/to/your/shell/script
    printenv:      
    SHELL=/bin/bash
    TMPDIR=/var/folders/4t/t1djbq6j5pj951x44l9hwxtc0000gn/T/
    Apple_PubSub_Socket_Render=/tmp/launch-mSKKJo/Render
    USER=<username_running_the_Applescript>
    SSH_AUTH_SOCK=/tmp/launch-7D4zpF/Listeners
    __CF_USER_TEXT_ENCODING=0x1F5:0:0
    PATH=/usr/bin:/bin:/usr/sbin:/sbin
    __CHECKFIX1436934=1
    PWD=/
    HOME=/Users/<home_dir_of_running_user>
    SHLVL=2
    LOGNAME=<username_running_the_Applescript>
    DISPLAY=/tmp/launch-qKucki/org.macosforge.xquartz:0
    _=/usr/bin/printenv
    Message was edited by: BobHarris

  • Can I embed a full shell script inside an applescript?

    I have a friend who is running Tiger on a PPC Mac and wants to download a large number of files from the web. Unfortunately, this friend is barely able to do basic web browsing with Safari or Firefox.
    I thought of just sending him a shell script with a lot of curl commands, but I don't suppose making it executable on my Mac would make it executable on his. I would like to be able to send him an Applescript that he could just run by clicking on it, but it would be awkward to make each curl command a separete shell script within the applescript..
    Is there a way of directly including in an applescript a multi-line shell script as a single entity that invokes only one shell? I know I can do it by putting the shell script in a separate file and have the applescript give it the necessary permissions, but then I'd have to explain to my friend where to put the shell script!

    While it is possible to do this in the Applescript if the shell script gets at all complicated escaping characters and debugging will be much harder then it needs to be.
    For example taking twtwtw's example and just adding one Applescript variable gives:
    set dir to POSIX path of (choose folder)
    set ss to "cd " & dir & "
    echo 'This is a file list for the \"" & dir & "\" folder'
    echo
    ls -l"
    set dlf to do shell script ss
    display alert dlf giving up after 10
    Twtwtw's suggestion of creating an Applescript application bundle is, I believe, the best way to go. You can keep the shell script and Applescript separate making maintenance and debugging much simpler and your friend just gets one 'file' to install and run.
    regards

Maybe you are looking for