Return results of cURL shell script direct to AS?

Is there a way to return the results of a cURL shell command (which I have working fine) directly to the AS script? The result of the cURL command is a small text file.
Or am I stuck with opening the resulting file to read its contents?

The solution is simple - your original shell example uses quoted strings, and you can't just copy/paste that into an AppleScript because AppleScript also uses quotes to delineate strings.
The answer lies in escaping the quotes, so that AppleScript knows to pass the actual quote symbol to the shell (and therefore onto curl) rather than have AppleScript interpret it itself.
do shell script "/usr/bin/curl --data \"browserRequest=true&lat1=43%C2%B043%2738.11%22&lat1Hemisphere=N&lon1=69%C2%B0 4 9%2752.85%22&lon1Hemisphere=W&startYear=2013&startMonth=1&startDay=1&resultForm at=csv\" http://www.ngdc.noaa.gov/geomag-web/calculators/calculateDeclination"
Note how the quotes surrounding your data are escaped.
(Note also that the above command generates a 500 error off the server because the parameter data is invalid, but I assume you can fix that)

Similar Messages

  • How to use the result of simple shell script?

    The shell script below retrieves the length of an audio file:
    set aFile to choose file
    do shell script "afinfo " & quoted form of (POSIX path of aFile) & "|grep duration"
    I'm wondering, how can I copy the result to the clipboard or set the value of a variable to it?
    Total newbie question. I have no idea about shell scripts - I just found the script above online.
    Thank you so much!

    Here:
    set the clipboard to (do shell script "afinfo " & quoted form of (POSIX path of aFile) & "|grep duration")
    or:
    set A to do shell script "afinfo " & quoted form of (POSIX path of aFile) & "|grep duration"
    (53997)

  • Shell script directed to one Dynamic Dashboard to monitor status of all DB

    Hi team,
    straight to scenario now..
    I have 15 databases to manage..i wrote shell scripts for monitoring each database status of ping,listener,vnc server, concurrent server, forms server, metric server, workflow, filesystem usage, alert-log etc..
    Now each and every time i will get 15 mails for one database each half n hour and it will get filled for sure if i get many alerts at single time...i thought of having a dashboard where my script output should display alerts on 3-D pie chart, bar chart etc..
    Imagine all databases statuses on one dashboard with colours displaying peaks and lows also the data gets dynamic changes every 30 mins.....
    charts will let me know to fix the issue easier..so next time i wont care how many mails reach me i will look up to dashboard and can observe what went wrong...
    please let me know any third party software available or self oracle or linux tools available.....
    hope anyone would give me suitable solution
    thanks
    dkoracle

    AFAIK Grid Control is completely free*, you just have to be careful to not go into the pages that require Management Pack licensing if you haven't purchased them for the DBs you're monitoring.
    Personally I have always used a combination of GC and shell script alerts. You don't want the GC environment to be your SPoF.
    *other than the associated server costs                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Can't get message from mailbox in shell script

    I'm using the shell-script workaround for the problem of creating messages from scripts run by a Mail rule. Can't seem to get the syntax right for getting a message passed from the main routine:
    Main
    <pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:800px">using terms from application "Mail"
    on perform mail action with messages theMessages
    repeat with eachMessage in theMessages
    set theID to id of eachMessage
    set theBox to name of mailbox of eachMessage
    set theAccount to "none"
    try
    set theAccount to name of account of mailbox of eachMessage
    end try
    do shell script "osascript Users/dave/Library/Scripts/Applications/Mail/exp.scpt " & theID & " " & theBox & " " & theAccount
    end repeat
    end perform mail action with messages
    end using terms from
    using terms from application "Mail"
    on run
    tell application "Mail" to set sel to selection
    tell me to perform mail action with messages (sel)
    end run
    end using terms from</pre>
    Shell
    <pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:800px">on run TheArgs
    using terms from application "Mail"
    set theID to item 1 of TheArgs
    set theBox to item 2 of TheArgs
    set theAccount to item 3 of TheArgs
    if theAccount = "none" then
    set theMessage to (message of mailbox theBox) whose id is (theID as integer)
    else
    set theMessage to (message of mailbox theBox of account theAccount) whose id is (theID as integer)
    end if</pre>
    The conditional is so I can test by selecting messages from either my Inbox or other boxes. Either way, though I get runtime errors like: "Can’t get «class mssg» of «class mbxp» \"INBOX\" of «class mact» \"David\" whose id of it = \"19111\". (-1728)"
    I've tried variations, but nothing seems to work.
    BTW, how does one view events or results in a shell script? Neither its window nor the main routine's show anything, and even "log" statements in the shell seem to go nowhere.

    I think I understand what's going wrong. If I select a message in my Inbox, the shell statement
    <pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:800px">set theMessage to (message 1 of mailbox theBox of account theAccount) whose id is (theID as integer)</pre>
    works. If I select a message from an On My Mac box, though, I can't get theAccount in Main in the first place because there's no account associated with those boxes. That's why I set up the "try" in Main and the conditional in the shell. I see now that
    <pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:800px">set theBox to name of mailbox of eachMessage</pre>
    in Main yields only the name of the box -- any containers it may have are omitted. Therefore,
    <pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:800px">set theMessage to (message 1 of mailbox theBox) whose id is (theID as integer)</pre>
    fails if there are any containers. So, I need a "set theBox" statement in Main that produces a proper path to the message, regardless of where it's located. If I can formulate that, a single "set theMessage" in the shell will suffice, without having worry about whether there's an account. I've experimented with "path to" and will continue casting about, but if the solution is apparent to you, please let me know.
    BTW: Echo was a worthwhile "little diversion" for me, because it's led me to a better understanding of what "do shell script" does (i.e., it executes a UNIX command as if it was typed into Terminal) and why it solves the message-creation problem (i.e., it runs the named script as a process that's separate from Mail). I suppose that was obvious to you and many others, but it wasn't to me, despite reading what the AS Language Guide says about it, plus a few Google hits for "osascript." So thank you for that.
    One thing I don't understand, though: If I change the command to "echo $1 $2 $3", nothing appears in Terminal. (I can produce files the way you showed just fine.)

  • Terminal vs "do shell script" - different behaviour processing extended characters

    Åäö won't be processed correctly by shell command "tr" when triggered by AppleScript.
    Result from Terminal (running shell "sh"):
    sh-3.2$ echo "ABCabcÅÄÖåäö" | tr "[:lower:]" "[:upper:]";
    Result: ABCABCÅÄÖÅÄÖ
    sh-3.2$ echo "ABCabcÅÄÖåäö" | tr "[:upper:]" "[:lower:]";
    Result: abcabcåäöåäö
    Result when running AppleScript "do shell script" (natively using shell "sh"):
    do shell script ("echo \"ABCabcÅÄÖåäö\" | tr \"[:lower:]\" \"[:upper:]\";")
    Result: ABCABCÅÄÖåäö
    do shell script ("echo \"ABCabcÅÄÖåäö\" | tr \"[:upper:]\" \"[:lower:]\";")
    Result: abcabcÅÄÖåäö
    I also tried a tip from another discussion - "/bin/echo" or "prinf" instead of just "echo".
    - Same result.
    Any suggestions how to overcome this?
    /Martin

    Hmm, thought you solved my problem but, sigh!, it seems the German Capital ß is a problem.
    More of a linguistic problem though so, thanks a lot anyway!
    http://en.wikipedia.org/wiki/Capital_ß
    Lowercase => uppercase
    Original lowercase
    abcdefghijklmnopqrstuvwxyzßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿþœšÿ
    Uppercase result using sh & tr in Terminal
    ABCDEFGHIJKLMNOPQRSTUVWXYZßÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝŸÞŒŠŸ
    Uppercase result using perl via applescript
    ABCDEFGHIJKLMNOPQRSTUVWXYZSSÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝŸÞŒŠŸ
    Difference: Lowercase ß => ß using sh but => SS using perl.
    Uppercase => lowercase
    Original uppercase
    ABCDEFGHIJKLMNOPQRSTUVWXYZßÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝŸÞŒŠŸ
    Lowercase result using sh & tr in Terminal
    abcdefghijklmnopqrstuvwxyzßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿþœšÿ
    Lowercase result using perl via applescript
    abcdefghijklmnopqrstuvwxyzßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿþœšÿ
    Difference: None.

  • 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

  • Call a Shell Script from a workflow

    Hi,
    I need to call a shell script from a workflow. How can I do this.
    If the script takes any input, How can I pass that input to the script
    and call the script in the workflow.
    Suggestions are needed.
    Thanks,
    Pandu

    Hi ,
    I am executing the following java code :-
    import java.io.BufferedWriter;
    import java.io.IOException;
    import java.io.OutputStreamWriter;
    public class SetPermissions {
         * @param args
         public void runCmd()
              System.out.println("inside runCmd()");
         Runtime r = Runtime.getRuntime(); //get runtime information
         try
         Process Child = r.exec("/bin/sh") ; //execute command
         System.out.println("child process created..");
         BufferedWriter outCommand = new BufferedWriter(new OutputStreamWriter(Child.getOutputStream()));
         outCommand.write("test.sh");
         System.out.println("command executed..");
         outCommand.flush();
         Child.waitFor(); //wait for command to complete
         System.exit(Child.exitValue());
         catch(InterruptedException e)
         { //handle waitFor failure
         System.out.println("ERROR: waitFor failure");
         System.exit(10); //exit application with exit code 10
         catch(IOException e)
         { //handle exec failure
         System.out.println("ERROR: exec failure"+e);
         System.exit(11); //exit application with exit code 11
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              SetPermissions setPer=new SetPermissions();
              setPer.runCmd();
    The shell script test.sh is changing the access permissions for a particular folder on Unix server. The code is not exiting , and the acces permissions on the folder are also not changing.
    If I execute the shell script directly , the access permissions gets changed on the folder. Please let me know the possible cause for this.

  • How to pass a result of SQL query to shell script variable

    Hi all,
    I am trying to pass the result of a simple SQL query that only returns a single row into the shell script variable ( This particular SQL is being executed from inside the same shell script).
    I want to use this value of the variable again in the same shell scirpt by opening another SQL plus session.
    I just want to have some values before hand so that I dont have to do multiple joins in the actual SQL to process data.

    Here an example :
    SQL> select empno,ename,deptno from emp;
         EMPNO ENAME          DEPTNO
          7369 SMITH              20
          7499 ALLEN              30
          7521 WARD               30
          7566 JONES              20
          7654 MARTIN             30
          7698 BLAKE              30
          7782 CLARK              10
          7788 SCOTT              20
          7839 KING               10
          7844 TURNER             30
          7876 ADAMS              20
          7900 JAMES              30
          7902 FORD               20
          7934 MILLER             10
    14 rows selected.
    SQL> select * from dept;
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    $ cat my_shell.sh
    ### First query #####
    ENAME_DEPTNO=`sqlplus -s scott/tiger << EOF
    set pages 0
    select ename,deptno from emp where empno=$1;
    exit
    EOF`
    ENAME=`echo $ENAME_DEPTNO | awk '{print $1}'`
    DEPTNO=`echo $ENAME_DEPTNO | awk '{print $2}'`
    echo "Ename         = "$ENAME
    echo "Dept          = "$DEPTNO
    ### Second query #####
    DNAME_LOC=`sqlplus -s scott/tiger << EOF
    set pages 0
    select dname,loc from dept where deptno=$DEPTNO;
    exit
    EOF`
    DNAME=`echo $DNAME_LOC | awk '{print $1}'`
    LOC=`echo $DNAME_LOC | awk '{print $2}'`
    echo "Dept Name     = "$DNAME
    echo "Dept Location = "$LOC
    $ ./my_shell.sh 7902
    Ename         = FORD
    Dept          = 20
    Dept Name     = RESEARCH
    Dept Location = DALLAS
    $                                                                           

  • How to get return code or parameters from PL/SQL in my shell script ?

    My shell script must check the result of PL/SQL's running, and decide what to do in the next step.

    I think you put the problem the wrong way.
    You should try to do as much as possible through your SQL scripts, and, if you need to make OS calls, you may do that using host(command_string).
    If you need to transfer parameters from other programs to your FORMS (PL/SQL), then you have to see user_exit.
    Some other means would be to have your PL/SQL write to certain OS files that the shell script may read, but that doesn't seem like good practice to me.

  • RFC_REMOTE_PIPE is Returning 1 alwasys and not able to execute Unix shell script

    Hello All,
    I am trying to execute a simple unix shell script from ABAP.
    What I did so far..
    1. created a test.sh file  with single command echo "Hello".
    2.  placed this file on application server /Usr/sap/test.sh
    3. executing ABAP program which as FM RFC_REMOTE_PIPE
    CODE:
    CALL FUNCTION 'RFC_REMOTE_PIPE'
       DESTINATION 'SERVER_EXEC'
    EXPORTING
       command  = lv_command
       read          = 'X'
    TABLES
       pipedate    =  lt_stdout
    EXCEPTIONS
    system_failure  = 1
    communication_failure = 2.
    if i populate lv_command  = echo "hello" it works fine
    if i give .sh file path in lv_command it is not working. it returns 1.
    Please help...
    I was searching SDN i found that rfcexec service should be enabled... how do i check that..
    i checked t code  \SMGW , i don't see any output...
    i checked FM GWY_READ_CONNECTED_SYSTEMS, i don't hsee anyting related to unix...
    Please suggest.

    I resolved the issue.
    It was issue with permission.
    Script file should have full permission ( Mode 777)..
    Thanks everyone.

  • Return codes from sqlldr command from unix shell script

    I am trying to capture error code from sql loader from unix shell script and display proper messages.
    sqlldr parfile=sdb.par control=$cntlfile data=$infile bad=$badFile log=$logFile rows=10000
    rows=10000
    retcode=`echo $?`
    case "$retcode" in
    0) echo "SQL*Loader execution successful" ;;
    1) echo "SQL*Loader execution exited with EX_FAIL, see logfile" ;;
    2) echo "SQL*Loader execution exited with EX_WARN, see logfile" ;;
    3) echo "SQL*Loader execution encountered a fatal error" ;;
    *) echo "unknown return code";;
    esac
    Eventhough, there are errors while executing sqlldr, it is always returing recode zero. What could be the possible reason
    Please advice

    Is there a typo in your code ?
    sqlldr parfile=sdb.par control=$cntlfile data=$infile bad=$badFile log=$logFile rows=10000
    rows=10000
    retcode=`echo $?` In this code, you get the return code of the statement in bold which is not the sqlldr statement ...

  • How do I start Firefox in Debian 5 directly from shell script without a dialog asking what to do?

    Running Debian 5.04. I downloaded the tarball from Mozilla website and extracted the files to my home directory. When I double-click on the Firefox start-up shell script, I get a dialog window asking if I want to run ina terminal window, display the shell's contents or run the program. Choosing "Run" starts Firefox successfully, but I'd like to by-pass the dialog and just have Firefox start. How to do this? TIA
    == This happened ==
    Every time Firefox opened
    == I unpacked the tarball to my home directory. ==
    == User Agent ==
    Mozilla/5.0 (X11; U; Linux i686; en; rv:1.9.0.19) Gecko/20080528 Epiphany/2.22

    Right click on the desktop and choose 'Create Launcher'. There enter the details so start the program directly not via a script. This did the trick for me for another program.

  • Automator - Run Shell Script - Does not return when script launches firefox

    Automator does not work the same on my MacBooks as my Mac mini! Both are latest Snow Leopard. I'm trying to automatically setup my MacBook after it decides if I'm at work, or elsewhere.
    The Automator Action "Run Shell Script" (Shell: /usr/bin/perl) does NOT return control when attempting to launch Firefox:
    system("/Application/Firefix.app/Contents/MacOS/firefox-bin -private news.google.com &");
    Note: the ampersand should cause Firefox to start as a background process.
    It only returns control after I close Firefox. I have a "Show Growl Notification" as the second action, so I know that the first action has not completed. Odd thing is that this works on my Mac mini. I also noticed that another difference: on my MacBook status is displayed in the top toolbar when the Automator application is running.
    Any ideas?

    Thanks, it worked. I forgot about stderr and stdin.
    I'm using Perl as it is part of a bigger script. I can quickly and easily figure out if I am at work where my MacBook is plugged into a network:
    my $ethernet = qx(ifconfig en0) =~ m{status:.active}xms;
    if ($ethernet) {
    # setup stuff for work environment
    } else {
    # setup stuff for mobile environment
    }

  • Why execution status of stored procedure in shell script is returning same?

    Hi Friends,
    My shell script has below code to execute Pl/Sql procedure.depending on pl/sql procedure status i need to execute the script further.
    i am testing error condition.So i kept exe instead of exec for executing procedure.it suppose to return non zero.But iam not getting the correct status in shell script using $?.
    even for error condition also status is returning zero(0).How to catch execution status of stored procedure in shell script?
    can you please me suggest whats is wrong in below code?
    echo "*************************************************************"
    echo "             cleaning replica tables"
    echo "*************************************************************"
    sqlplus -s migrat/****@dotis01<<ENDOFSQL
    WHENEVER SQLERROR EXIT 1;
    exe PKG_OTU_HELPER.SP_CLEANUPREPLICA;
    Commit;
    exit;
    ENDOFSQL
    status=$?
    echo $status // showing 0 always.
    +if [ $status -ne 0 ]+
    then
    echo "issues in cleaning in replica tables"
    exit;
    fi
    +#Loading of data from flat files to migration tables using sqlldr programs+
    echo "*************************************************************"
    echo "      Loading of data from flat files to migration tables"
    echo "*************************************************************"
    sh /opt/finaclesoftware/UBS_10.4.02_AIX/AIX/DB/CRM/Oracle/OTU/Retail/ControlFiles/LoadData1.com
    Thanks,
    Venkat Vadlamudi

    The whenever sqlerror clause is a sqlplus command. When Oracle (that is, the sql engine of the pl/sql engine) raises and error in a sql statement, the whenever sqlerror command determines what happens.
    Exec is also a sqlplus command, exec <procedure> is shorthand for begin <procedure> end;, that is, it creates an anonymous block.
    Your misspelling of exec as exe is not an Oracle error, it is a sqlplus error. The command never actually gets to Oracle, so there has not been a sqlerror for whenever sqlerror to respons to.
    Consider, I do not have a procedure called p
    SQL> desc p
    ERROR:
    ORA-04043: object p does not existI try to call it with exe as in your code:
    SQL> exe p;
    SP2-0042: unknown command "exe p" - rest of line ignored.Note the error message is form sqlplus (SP2).
    But, if I call it correctly usinf exec:
    SQL> exec p;
    BEGIN p; END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00201: identifier 'P' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignorednow I have a sql error, and whenever sqlerror exit 1 would quit sqlplus with a return value of 1.
    John

  • Shell Script: Timeout and return error if Sqlplus hangs

    Shell Script: Timeout and return error if Sqlplus hangs
    Dear all,
    This morning, our production database hung with lots of ORA-600 and 7445. The issue has been escalated to Oracle Tech support but my monitoring script which tries to make a connection every 5 mins to the database to see if its up, did not alert me. The reason is that, it connected to the database and hung, never came out to report an error and so I never got alerted until a user called me.
    Can any one tell me how I can exit from the sqlplus block if I dont get a response in x seconds? This sqlplus block is being called with in a shell script.
    Any help is highly apprciated.

    I don't know of anything built into any shell scripting language that would do this, no. I'm not a Perl programmer, but I have a vague recollection that Perl may have something useful here.
    From the "separate thread" part of my comment, though, you could certainly spawn a separate thread (thread 2), have thread 2 wait a period of time, then look for a message from thread 1 and throw an error if the message hadn't been sent. I don't know that I'd be for writing multi-threaded shell scripts, though. The heartbeat also gives you a layer of redundancy so that something is monitoring the monitor in case that process stops working.
    Justin

Maybe you are looking for

  • Preview and Printing Document Problems

    I am new to Adobe Livecycle and have been askedto create some forms to be placed on the internet.  Please note that I am a user and not a programmer. I am in version 8.2.  I have created a form and believe I have it in the correct format. I created m

  • Error in BPELProcess1.bpel(137): !!BPELC_PA__OMIT!Choice Pattern incorrect

    Using Oracle 11g JDeveloper 11.1.1.5.0 error: in BPELProcess1.bpel(137): !!BPELC_PA__OMIT! [0=java.lang.IllegalArgumentException: Choice Pattern incorrect,1=null,2={2},3={3},4={4},5={5}] Thanks in advance.

  • TP 600X Always Boots to Easy-Setup

    Hello... It's a 600X 2646-D3U. BIOS is BIOS ITET55WW, 11/30/99 I bought it used in 2004 and it has served two kids reasonably well. They've moved on to more current hardware and I'm trying to bring it back to life.  I replaced the 'button' battery, t

  • Standard transactions and WS

    Hello SAP gurus. This time i want to ask about webservices and standard transactions. so this is the deal: - It is possible to transform a SAP standard dialog transaction (wich doesnt have a related BAPI) and become into a webservice? - If that so, i

  • Diffrent coordinates between Scene builder and javafx

    Hello, I'm building an image using javafx, i don't want to use fxml, but i tried to use scene builder to help me identify my object corrdinates. I have to add a background picture and to add some other graphic object, when using exactly same coordina