Synchronous AppleScript using osascript

Hello all,
I have a java app I'm putting ical integration into. Contrary to popular belief, it actually works very well by having the java call osascript which is calling an AppleScript. Everything is great, but then I started getting a lot more events in ical to sort through.
It looks like the osascript and or the applescript are being executed asynchronously.
The option I'm considering, but don't like because of the cheese factor, is to have the applescript create a file at the beginning of the script and destroying it at the end. The java app could then loop (and sleep) while the file exists. Gross, but possibly effective semaphors.
Anyone run into this or have a better idea?
many thanks in advance!

Hello
I, too, am not sure what you're after by such a complicated device.
Anyway, I think one problem lies in how you quote the argument. Parameter expansion won't take place in single-quoted string.
Try something like this:
argv='{name:\"someone\"}'
osascript -e "set x to run script \"$argv\"" -e 'return name of x'
Or:
argv='{name:\"someone\"}'
osascript <<-EOT
set x to run script "$argv"
return name of x
EOT
(They are NOT tested. Also please copy code from this web page, not from subscribed email text, for I escaped some characters for posting.)
cf.
http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/bash.1.h tml
QUOTING
EXPANSION
REDIRECTION
  Here Documents
Regards,
H

Similar Messages

  • Automator or Applescript using png files with alpha channel

    I have hundred of png files with alpha channel.
    I want to suppress alpha channel.
    How can i do it using Automator or Applescript ?
    Thank you very much.

    You can use the free command line image processing tool ImageMagick in your Applescripts or Automator workflows, as well as from a Terminal shell.
    You can download ImageMagick from http://www.imagemagick.org, but Cactuslab has simplified installation by putting together an installer package. It’s available at  http://cactuslab.com/imagemagick/. Download the package and double-click on it. Follow the instructions to install. It will install ImageMagick into /opt/ImageMagick and add it to your $PATH by creating a file in /etc/paths.d/. Restart your computer for the changes to take effect.
    The two ImageMagick commands we’re concerned with are “convert” and “mogrify”. Convert is more efficient for multiple and piped operations on the same image file, and mogrify is more efficient for batch processing. Generally speaking, convert will output a file separate from the input file. Unless a path is specified, mogrify will overwrite the input file with the output file. An important distinction.
    You can perform various operations on the alpha channel using arguments after either the convert or mogrify command. Two of the available arguments are:
    -alpha off - Disables the image's transparency channel. Does not delete or change the existing data, just turns off the use of that data.
    -alpha remove - Composite the image over the background color.
    Also of use are the -flatten and -background options:
    -flatten - overlay all the image layers into a final image and may be used to underlay an opaque color to remove transparency from an image.
    -background - sets the background color.
    Start off using the convert command with a single image to see the effect and adjust to your liking. Once you’ve achieved the desired outcome, then use the mogrify command to batch process the chosen images.
    Before getting into how to use Automator or Applescript in your workflow, use Terminal and the command line to see the effect on a single image. Copy one image to your ~/Desktop. In Terminal change the directory to ~/Desktop by typing the following command and pressing the Enter key:
    cd ~/Desktop
    Then choose the option you are looking for, -alpha remove for instance, type the following command and press the Enter key:
    convert input-photo.png -alpha remove output-photo.png
    You can check the alpha channel (transparency) and background in the Preview app, go View > Show Image Background from the menu bar.
    Once you’re ready to batch proces, place all the photos you want to convert with the same command into one folder. Copy the folder to your ~/Desktop. Let’s assume you’ve labeled the folder “InPhotos”. It’s prudent to manipulate copies in case something goes amiss. In that event you can copy the folder with the originals again and start over. Create a new empty folder on your ~/Desktop and call it “OutPhotos”. Let’s also assume your home directory is called “Me”. The following command will process the photos from the InPhotos folder and put them in the OutPhotos folder:
    mogrify -alpha remove -path /Users/me/Desktop/OutPhotos/ /Users/me/Desktop/InPhotos/*png
    According to Apple Technical Note TN2065:
    "when you use just a command name instead of a complete path, the shell uses a list of directories (known as your PATH) to try and find the complete path to the command. For security and portability reasons, do shell script ignores the configuration files that an interactive shell would read"
    So, you need to use the full path to to ImageMagick commands, unlike in the shell where you can just use the command name.
    To batch process using Automator, use the “Run Shell Script” action (note: retain the single space at the beginning of the last line):
    /opt/ImageMagick/bin/mogrify \
    -alpha remove \
    -path /Users/Me/Desktop/OutPhotos/ \
    /Users/Me/Desktop/InPhotos/*png
    To batch process using Script Editor (Applescript), use the “do shell script” command:
    do shell script "/opt/ImageMagick/bin/mogrify -alpha remove -path /Users/pd/Desktop/OutPhotos/ /Users/pd/Desktop/InPhotos/*png"
    Further info on ImageMagick:
    http://www.imagemagick.org/script/command-line-options.php#alpha
    http://www.imagemagick.org/Usage/masking/#remove
    http://www.imagemagick.org/index.php
    http://www.imagemagick.org/script/command-line-tools.php
    http://www.imagemagick.org/script/command-line-options.php
    Examples:
    The original PNG image:
    -alpha off:
    -alpha remove:
    -background black -flatten:
    -background blue -flatten:
    -channel alpha -evaluate Divide 2:
    -channel alpha -evaluate Divide 2 -background black -flatten:

  • Issue in Synchronous OSB using Jms Queues in OSB11g

    Hi,
    I am working on building a synchronous OSB using the following steps.
    1)     Creating the Synchronous OSB Proxy Service which routes the message to the business service which in turn places a message in the Queue(inqueue) by populating the JMSCorrelationId and waits for the response message to consume from another queue.
    2)     A Composite(SOA) will consume the message from this Queue
    3)     It will do necessary transformation and Places it in another Queue (Say Response Queue).
    4)     OSB Business service waiting in Step 1 will receive the response from this response Queue.
    I used a sample Wsdl which has both request and response message types.
    I observed that the correlation ID is maintained properly from inqueue to response queue. But the message is not getting picked up by OSB from the response Queue
    Twist: It is working absolutely fine in OSB 10g but it is not working in OSB 11g.
    I tried using Messaging service as well as using the sample WSDL i.e keepiing the soap message in the queue. Both the cases are working absolutely fine OSB 10g but not in OSB 11g.
    Can anyone faced a similar issue or any pointers will be great help in this regard.
    Regards,
    Ashok

    To debug this further can you check if the response Q has any active consumers. ? When you use response by correlation ID business service, OSB actually creates MDB's with message selectors under the hood.
    This is a sample of the ejb-jar.xml of the MDB created for a business service with response by Correlation ID pattern.
    <?xml version='1.0' encoding='UTF-8'?>
    <jav:ejb-jar xmlns:jav="http://java.sun.com/xml/ns/javaee">
    <jav:display-name>BEA ALSB JMS Outbound Sync-Async Endpoint</jav:display-name>
    <jav:enterprise-beans>
    <jav:message-driven>
    <jav:ejb-name>ResponseEJB-6577847719916437493-3893eeb7.1287d30ba4f.-7fe1</jav:ejb-name>
    <jav:ejb-class>com.bea.wli.sb.transports.jms.JmsAsyncResponseMDB</jav:ejb-class>
    <jav:transaction-type>Container</jav:transaction-type>
    <jav:message-destination-type>javax.jms.Queue</jav:message-destination-type>
    <jav:activation-config>
    *<jav:activation-config-property>*
    *<jav:activation-config-property-name>messageSelector</jav:activation-config-property-name>*
    *<jav:activation-config-property-value>JMSCorrelationID LIKE 'ID:424541534594cf52%'</jav:activation-config-property-value>*
    *</jav:activation-config-property>*
    </jav:activation-config>
    <jav:env-entry>
    <jav:env-entry-name>service-ref</jav:env-entry-name>
    <jav:env-entry-type>java.lang.String</jav:env-entry-type>
    <jav:env-entry-value>BusinessService$Test$RequestQ</jav:env-entry-value>
    </jav:env-entry>
    As you can see the message selector is based on JMSCorrelationID LIKE 'ID:424541534594cf52%'. This means the business service will pick only those messages which has its correlation ID starting with ID:424541534594cf52.
    You can see the message selector for your MDB from admin console --> deployments.
    Check and confirm if the correlation ID created in the request also starts with this value and the same is send back from the server. Also try deleting and recreating the business service or rename the business service which will create a new MDB under the hood and check the above.

  • Synchronous UART using PCI-6251

    Hello
    I am a beginner using LabVIEW and I need to create a synchronous UART using the PCI-6251, meaning, using one digital I/O to generate clock while another one shifts the data bit-by-bit. It has to work as a master in a half duplex mode. (LabVIEW always providing the clock but data flowing in one direction at a time).
    Could someone help me?
    Thanks!

    Hello, 
    It looks like your application is similar to the one in this forum. However the hardware in the forum is an X-Series in which the digital I/O has a dedicated sample clock and the PCI-6251 is an M-Series which requires you to provide the sample clock.  In order to accomplish what you are describing you will need to create a counter output task to use as your sample clock for the digital output and also to export on a PFI line.  An example of using a counter to correlate the digital output can be found by opening LabVIEW and navigating to Help»Find Examples»Hardware Input and Output»DAQmx»Digital Generation and selecting the Correlated Dig Write With Counter.vi.
    Thank you,
    Justin P 
    Justin
    National Instruments
    Product Support Engineer - Conditioned Measurements

  • How to run an applescript using unix command

    Hi All,
    Can any one help me in giving me the command for running an apple script thru postupgrade shell file in other words i wana run an apple script while running my new installer that will upgrade the old version of application but while installing i want to run an applescript so as i know ill have to give that applescript path in the postupgrade script but how to run it while installation and where to keep it (is it postupgrade). May be in short how can i run apple script thru unix command.

    Use the osascript command.
    In my installer, I use the DropDMG program to build my DMG disk image. It doesn't quit automatically, so I have to do the following:
    osascript -e "tell application \"DropDMG\" to quit"
    Type "man osascript" for more information.

  • JDBC Synchronous call  using BPM

    Guys,
    Scenario is like this.
    1. Initiator is file adopter
    2. JDBC select (Synchronous call) select data from 1 DB table
    3. Copy response into some FTP system as a file.
    File Initiator is working fine Synchronous call is giving the error.
    I have created the Message Interfaces
      1. Synchronous abstract (JDBC_select)
      2. Asynchronous abstract (JDBC_Select)
    I have done the 2 mappings like
    1. File Initiator as source and JDBC_Select as target,
       (I am passing all constants values to JDBC_select like action='SELECT' table='tablename' and keys as well)
       JDBC_Select structure i have created as
           <Root>
             <selectStatement1>
             <action>
             <tablename>
             <access>
             <c1>
             <c2>
             <key>
             <c1>
    2. JDBC_response as source to Target_FILE as target.
       Response structure is like this
        <root>
        <row>
        <c1> </c1>
        <c2>...</c2>
        </row>
        </root>
    I have created the BPM by using
      --> transformation and send steps.
    Can any body send me the Blogs for this scenario .
    Thanks
    M

    Moorthy,
    <u>Message Types</u>
    1) File_Input
    2) JDBC_Req
    3) JDBC_ Response
    4) Target_File
    <u>Message Interfaces</u>
    1) Async_Outbound,
         - File_Input
    2) Async_Inbound
         - Target_File
    3) Async_Absract
         - File_Input
    4) Sync_Abstract
         - Target_File (Output Message)
         - JDBC_Response (Input Message)
    5) Sync_Inbound
         - JDBC_Request (Input Message)
         - JDBC_Response (Output Message)
    <u>Message Mapping</u>
    1)Mapping1
      - File_Input as a Source
      - JDBC_Reqest as Target(Here I am passing all constants values like action, tablename , accessfields and keyfields)
    2)Mapping2
      - JDBC_Response
      - Target_file (Target file structure as same JDBC_Response structure)
    <u>Interface Mapping</u>
    Interface Mapping 1
       - Sync_Abstract (source Interface)
       - Sync_Inbound  (Target Interface)
    Here is my doubt I am not getting Mapping program in the dropdown (F4 help), it is problem with my source and target?.
    What are the source and target for second interface mapping.
    Thank you for helping me alot on this..
    M

  • Synchronous scenario using receiver mail adapter

    Hi All,
    I am trying to do a Http to Mail synchronous scenario. My requirement is, if the mail has been delivered to the reciver mail server, it should send an acknowledgement/response back to XI. Simlarly when it fails to deliver the message it should send an acknowledgement/response back to XI.
    Is it possible to do? If yes, please tell me how can i do this?
    Thanks & Regards,
    Senthil.

    >
    prakasu wrote:
    > Hi,
    >   In the mail receiver adapter mark the check box send delivery status notification.It will give the acknowledgement to the from address mail is deliverd or fails.There is no need of synchronous scenario.
    >
    > Regards,
    > Prakasu.M
    using this method a delivery ack mail is send to the TO address as rightly pointed out.
    Now senthil, if you want to you can have a mail sender adapter polling for mails and you can maybe correlate the To address using a BPM and then recognize this to be a delivery ack for the mail you send. Its not concrete as maybe a delivery ack might say it was not successfully delivered too so then you might have to enhance your logic to check the content to see what the mail is all about. Pheww ....
    Doesnt seem right.. so I gather the best is to redesign the interface if the flexibility is in your hands.
    Other option is to have a acknowledgment request in your Send step of the BPM

  • Logging a synchronous message using diagnostic header (WITHOUT LOGGING_SYNC

    This [link|http://help.sap.com/saphelp_nw70/helpdata/EN/d6/49543b1e49bc1fe10000000a114084/frameset.htm] indicates that a synchronous message can be logged by using:
    <SAP:Logging>1</SAP:Logging>
    within the message header even if LOGGING_SYNC is deactivated at the server configuration. 
    I'm using HTTP client tool to submit a message and trying to figure out how to pass this tag.  Any ideas?
    Regards,
    Shahab

    If  LOGGING_SYNC  is deactivated in IE Configuration, then you cannot see th req. and resp. message in MONI.
    Synch. messages are not persistence by default. To acheive it, we need to set the logging.
    Thanks
    Farooq.

  • Updation in synchronous mode using bapi

    hi all ,
           i have a requirement to update master table using bapi /SAPMP/BAPI_MATERIAL_SAVEDATA  where has it is taking more time can any one of you sugguest what will be the best approach which i can improve the execution time and can u tell me whether i can execute bapi in synchronous mode.
    with regards,
    abaper

    Hi,
    You can go for either BDC or LSMW also.
    Regards,
    Renjith Michael.

  • Make synchronous calls using JCo

    Hi everyone,
    I have done an integration project using JCo talking to the SAP system. The task would be creating a document (BAPI_DOCUMENT_CREATE2), and then checking in the content (BAPI_DOCUMENT_CHANGE2). I found sometimes the document created in step1 did not exist or was locked, then step2 failed.
    I checked the JCo Javadoc, and found that JCo.client.execute(function) would make synchronous call to the SAP system. I supposed that it would make the second call only after the first call finishes.
    Am I right about the assumption?
    Could someone share some ideas about this as well as the transactional mode (asynchronously) call where JCo.client(function, tid) is used?
    Thanks in advance.
    Xueqing Han

    Hi hanan20,
    Welcome to the Microsoft Mobile Community.
    Let's isolate the issue. Are you unable to make any calls regardless of the signal strength and your location? Were you able to receive calls, send or receive text messages? Are you using a regular Micro-SIM or a modified SIM? Have you tried the workarounds given on the link below?
    • I cannot make a call
    Note: The link is intended for the Philippines. If you're outside this country, you can visit your local support for future reference. See: Local support.
    We look forward to your reply.

  • Running Applescript using cron jobs not working

    I'm new to conjobs and applescript but I have the script done correctly i believe. (any critique is welcome) I don't want to bloat my calendar with events to do this because I use my calendar for appointments and I don't need the bloat.
    Here's my goal: run an apple script at 9am/5pm to enable/disable a mail account (after this works I'm going to add loging in/out of an Messenger account, first things first)
    here's my script:
    tell application "Mail"
              set offTime to 17
              set onTime to 9
              set dayOfWeek to weekday of (current date)
              set theHour to get the (hours of (current date)) as string
              if theHour ≥ onTime then
                        say "email on"
                        set enabled of account "MAILBOX" to true
              else if theHour ≥ offTime or (dayOfWeek = Saturday or dayOfWeek = Sunday) then
                        say "email Off"
                        set enabled of account "MAILBOX" to false
              end if
    end tell
    accessing cron jobs via this
    sudo pico /etc/crontab 
    and within cron jobs i've used
    0 9 * * * username osacript
    "/Documents/disablemail.scpt"
    0 17 * * * username osacript
    "/Documents/disablemail.scpt"
    variations I've attempted (based on search engine results)
    0 9 * * * username osacript
    "~/Documents/disablemail.scpt"
    0 9 * * * /Documents/disablemail.scpt
    0 9 * * * ~/Documents/disablemail.scpt
    0 9 * * * osacript /Documents/disablemail.scpt
    0 9 * * * osacript ~/Documents/disablemail.scpt
    I think that's all of them.
    Any feedback/assitance appreciated, thanks!

    What's the problem, is the cronjob not getting called at all or is the script giving errors?
    One problem you have right off is the cron job you have set up is running as root not as you.

  • Synchronous writes using FileAdapter

    Hi all,
    I'm new to this SOA and BPEL stuff so I'm probably missing something obvious.
    I'm writing out a file using a File adapter. This works fine.
    The problem is when calling the invoke it invokes the FileAdapter as an async process. After the file is written there is a second(non soa/bpel) background process that is run to do some other processing on the file. However, with it being asynchronous we run into a situation where the second process can begin processing a file without it being completely written out yet.
    How do we go about preventing this situation or at the very least is there a way to make the file adapter invoke synchronous?
    Thanks!

    there is a way to activate the processing of a file using a trigger file;
    you should create the trigger file only after completion of the creation of the main file
    consumption of the main file is activated by the trigger file
    hope it helps

  • Call JavaScript from AppleScript using InDesign CS2

    Can this be done?
    The following script:
    tell application "Adobe InDesign CS2"
    tell active document
    do script "var thisNumber = 5;" language javascript
    end tell
    end tell
    results in the error:
    tell application "Adobe InDesign CS2"
    do script "var thisNumber = 5;" language javascript
    "Adobe InDesign CS2 got an error: \"var thisNumber = 5;\" doesnt understand the do script message."
    Why doesn't this work and what can I do to fix it?
    William

    On 4/12/08 5:41 AM, "Olav Kvern" <[email protected]> wrote:<br /><br />> These sorts of things are hard to see in AppleScript, because the dictionary<br />> browser(s) don't group methods with their parent objects. Sal Soghoian at<br />> Apple has long said that this needs fixing.<br /><br />And in fact it has been fixed -- it just needs app developers to write their<br />dictionaries appropriately. For a good example, have a look at the<br />dictionary of Script Debugger 4.5 -- you'll see classes listed with<br />elements, properties, and "Responds to". And none of that truncation ID's<br />dictionary is full of.<br /><br />-- <br />Shane Stanley <[email protected]><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>

  • Error Synchronizing Calendar using Desktop Manager 4.7, Outlook 2003, on the Storm

    I just installed Desktop Manager on my PC (Windows XP).
    Contacts sync fine.
    Calendar does not sync:
    "Reading Device Calendar" goes fine.
    "Processing Device Calendar" goes fine.
    "Reading from MS Outlook Calendar" is where the error happens:
    Desktop Manager begins reading the 988 Outlook items and consistently stops at item #227, with one of two error messages:
    1) "Intellisync, Unknown Error Reported" or
    2) "Operation Terminated Unexpectedly."
    I followed directions for:
    How to turn on advanced logging for Intellisync due to BlackBerry smartphone synchronization failureat
    http://www.blackberry.com/btsc/microsites/search.do?cmd=displayKC&docType=kc&externalId=KB01451&slic...
    This operation required that I modify the iloptcfg.cfg file.
    Still no luck. any suggestions?
    Solved!
    Go to Solution.

    there is a method involving enabling detailed logs on the Desktop Manager. Then it will give information about that 227th item. check the forum or th public knowledge base (click on the "SUPPORT" button on top of the present page)
    if I were you, I'd just wipe the calendar database on the device, do the sync, and when it stops : open the calendar on the device and see the last event synchronized. it should be the 226th.
    The search box on top-right of this page is your true friend, and the public Knowledge Base too:

  • Resize Canvas applescript using the relative tick?

    I'm using this
    tell application "Adobe Photoshop CS6"
      resize canvas height -1 anchor position top center
    end tell
    I want to reduce the size of the image by 1 pixels from the top center. But when I do it manually I would use the "relative" check box,
    How can I do this?
    please

    tell application "Adobe Photoshop CS5"
              tell document 1
      resize canvas height (height - 1) anchor position top center
              end tell
    end tell

Maybe you are looking for

  • Preview show all attachment (pdf) as locked

    just i want to ask about why (preview.app) show all attachment (pdf) as locked and when you want to unlocked press in the top of file to open it , why there is some step to do this ,not like before in snow leopard. and how i install old preview to wo

  • Vendor description in MB51

    Dear All In the report MB51 Vendor and customer numbers are displaying. But my client wants the description along with the number. I have checked the layout .But description is not their. Kindly kind me to achieve. Shobana

  • Why do the Screensaver not show pictures from my Aperture Library?

    Hello, I have a new MacBook Retina and everything is fine, but the screensaver. When I choose a screensaver with photos (like Ken Burns) and an Aperture folder, the screensaver only shows "Fotos laden..." (German for "Loading pictures..."). When I ch

  • BDC programming and table controls selColumns

    Hello, I have a small question regarding BDC programming. I am already quite familiar with the process in creating one but I have one question regarding table control and its selColumns. Transactions like pa40 would require its users to select one of

  • When i create an apple id option none does not appear

    when i create an apple id option none does not appear