Why does this script not work when run with osascript cli?

I wrote the following to interface with geektool to display a list of todo's on my desktop (i'm sure it's been done elsewhere, but I wanted to try it myself). I had it working fine until I tried ordering the output to place the highest priority items at the top of the list. The following code works properly during development in Script Editor, but when geektool launches the command using osascript ~/Library/Scripts/todos.scpt it only displays the initial "TODOS:" without displaying the rest of the info. Searching the Applescript Release notes, I found that some versions of Applescript 1.8 had issues with null characters when using the osascript cli, however, I'm running 1.10.7 so it shouldn't be an issue (and I'm not sure how to check for null characters in Applescript even if it were). Anybody have any ideas on what's going on here?
set output to {"TODOS:
set highpri to {}
set medium to {}
set low to {}
set nada to {}
tell application "iCal"
repeat with i in calendars
repeat with j in todos of i
if (completion date of j as string) is equal to "" then
if priority of j as string is equal to "high priority" then
copy summary of j & "
" to end of highpri
end if
if priority of j as string is equal to "medium priority" then
copy summary of j & "
" to end of medium
end if
if priority of j as string is equal to "low priority" then
copy summary of j & "
" to end of low
end if
if priority of j as string is equal to "no priority" then
copy summary of j & "
" to end of nada
end if
end if
end repeat
end repeat
end tell
return (output & highpri & medium & low & nada) as string

well, i'd been pulling my hair out for quite a while with this and decided it was time to ask for help, but I thought I'd give it one last shot and found a resolution almost immediately. I figured that problem had to be caused by the way applescript was concatenating the lists, so I got rid of the lists completely and it still wouldn't work. This convinced me that it must be newline related since that was the only special character left in the string. I opened up the script in vi, but the default compiled script format is not human readable. The osascript man page indicated that it would accept both compiled and text scripts, so I gave it a try, and osascript handled the raw text file wonderfully.

Similar Messages

  • HT4993 why does my internet not work when not connected to wifi?

    why does my internet not work when not connected to wifi

    Hi farmgirl0812,
    Thanks for using Apple Support Communities.  This article has steps to try if you are unable to connect to a cellular network:
    iPhone: Troubleshooting a cellular data connection
    http://support.apple.com/kb/ts3780
    Cheers,
    - Ari

  • Why does the alarm not work when the iphone 4 is turned off

    why does the alarm not work when the iphone 4 for is  turned  off works fine when on most other phones work when off

    The only phone I've ever had that would turn on and sound the alarm is a Blackberry. So, I'd hardly say "most phones" have this function.

  • Why does the mail not work when i updated my 5s to iOs 8?

    why does the mail not work when i updated my 5s to iOs 8?

    Thank you for the reply. But can you tell me what this configuration is about and how I should do this?

  • Why does this websites not work on our Mac products?

    http://www.gordonbennett2012.ch/
    We are working on the above website: We cannot get it to work on the following Mac devises. Would you please advise the reason for this and how we can fix it?
    From: FLY GAS
    Subject: Fwd: Website of Gordon Bennett 2012  
    Date: August 11, 2012 1:52:22 PM MDT
    To: René Louis  Cc: Mark Sullivan
    Hello René,   Thank you very much for your email. I am happy to work with you. I have been working on this all day. I still have not figured out why this is not working. I am Mark Sullivan and Cheri White's Crew Chief/Technical Support for the USA.
    The following products are being used:
    MacBook Pro,Mac OS X Version 10.7.4, Processor 2.8 GHz Intel Core 2 Duo
    Mac iPad, Version 5.1.1 (9B206)
    Non of these prodects will upload your site    http://www.gordonbennett2012.ch/
    I have tried the following browsers:
    Opera: Could not connect to remote server,
    Safari: no responce
    Firefox: The connection has timed out                                                                The server at gordonbennett2012.ch is taking too long to respond.
    Google Chrome: Oops! Google Chrome could not connect to www.gordonbennett2012.ch
    I have had all our crew do the same. They are in different parts of the USA.
    And the response has been the following:
    North Carolina on PC and Android: Site uploaded
    New Mexico on PC and iPhone: Site did not upload on either
    New Mexico on PC and iPhone: Site did upload
    I have also contacted Mac. Please let me know your thoughts so we can sort this out.  In the past I have been able to get your site. Just in the past month I have not been able to. I am getting a timed out error from ALL the above browsers.
    Kind regards,  Letitia
    Ms. Letitia Hill
    TEAM USA/FLY GAS
    PO Box 7186
    Albuquerque, New Mexico 87194 USA
    TEL: 505-270-6759
    FAX: 505-503-8430
    E-Mail: [email protected]
    Website: www.flygas.net
    Begin forwarded message:
    From: René Louis 
    Subject: Website of Gordon Bennett 2012 Date: August 11, 2012 1:25:13 PM MDT
    To: [email protected]
    Dear Letitia  Thank you very much for your message about our website.
    I am also working with a Mac and could not find any problems.  I would be very interested to know which products you are using and what is not working so I could have a detailed look at it.
    Thank you very much.
    Best Regards
    René
    Gordon Bennett 2012 Secretariat / Postfach 280 / CH-9650 Nesslau / Switzerland www.gordonbennett2012.ch  René Louis / Kirchweg 672 / CH-9650 Nesslau / Switzerland

    There seems to be a block with the Internet server in the United States as other Internet and cell servers i.e. Verizon and Century-Link DSL work with Mac, Andriod and PC. It just seems to be Mac on Comcast that is not...
    Without more data I'm inclined to say it's more likely to be Comcast itself, rather than 'Macs on Comcast'.
    For example, do other devices (PCs, Android, iOS) on that Comcast network also have problems connecting? or do they connect fine?
    I'd expect that any device at that network has a problem, which indicates a problem with Comcast. It might be their DNS not resolving properly, or them not routing data correctly, but that should be your focus.
    Perform a DNS lookup on the www.gordonbennett2012.ch hostname. What result do you get? Is it the expected address?
    If that returns the right address, what do you get with a traceroute?
    That will test the routing befween your system and the server, and may indicate other problems on the network.

  • Repaint() an applet from a swing applet, why does this code not work?

    below are three files that work as planned except for the call to repaint(). This is envoked when a button is hit in one applet and it should repaint another applet. I opened them up in a html file that simply runs both applets. If you could see why the repaint doesn't work I'd love to know. good luck.
    //speech1
    import java.awt.*;
    import java.applet.Applet;
    import java.awt.event.*;
    //java extension packages
    import javax.swing.*;
    public class speechapp1 extends JApplet implements ActionListener{
    // setting up Buttons and Drop down menus
    char a[];
    Choice choicebutton;
    JLabel resultLabel;
    JTextField result;
    JLabel enterLabel;
    JTextField enter;
    JButton pushButton;
    TreeTest PicW;
    // setting up applets G.U.I
    public void init(){
    // Get content pane and set it's layout to FlowLayout
    Container container = getContentPane();
    container.setLayout( new FlowLayout() );
    // initialise buttons and shit
    a = new char[30];
    choicebutton = new Choice();
    enterLabel = new JLabel("Test");
    enter = new JTextField(30);
    resultLabel= new JLabel("speech label");
    result = new JTextField(30);
    result.setEditable(false);
    // Add items to Choice Button
    choicebutton.addItem("abc");
    choicebutton.addItem("def");
    choicebutton.addItem("ghi");
    choicebutton.addItem("jkl");
    pushButton = new JButton("Click to continue");
    // Add new Tree from file TreeTest.java
    PicW = new TreeTest();
    // Add buttons to container.
    container.add(resultLabel);
    container.add(result);
    container.add(enterLabel);
    System.out.println("");
    container.add(choicebutton);
    System.out.println("");
    container.add(pushButton);
    pushButton.addActionListener(this);
    //choicebutton.addActionListener( this );
    // Set the text in result;
    result.setText("Hello");
    //public void paint(Graphics gg){
    // result.setText("Hello");
    public void actionPerformed(ActionEvent event){
    // continue when action performed on pushButton
    String searchKey = event.getActionCommand();
    System.out.println("");
    if (choicebutton.getSelectedItem().equals("abc"))
    PicW.getPicWeight(1);
    if (choicebutton.getSelectedItem().equals("def"))
    PicW.getPicWeight(2);
    if (choicebutton.getSelectedItem().equals("ghi"))
    PicW.getPicWeight(3);
    if (choicebutton.getSelectedItem().equals("jkl"))
    PicW.getPicWeight(4);
    System.out.println("repainting from actionPerformed method()");
    PicW.repaint();
    import java.applet.Applet;
    import java.awt.*;
    import java.util.*;
    public class TreeTest extends Applet{
    Tree BackgroundImageTree;
    Tree PlayerImageTree;
    Image snow,baby;
    int weight;
    public void getPicWeight(int w){
    weight = w;
    System.out.println("the new weight has been set at: "+weight);
    this.repaint();
    public void init()
    // initialising trees for backgound images and player images
    BackgroundImageTree = new Tree();
    PlayerImageTree = new Tree();
    // initialising images and correcting size of images to correctly fit the screen
    snow = getImage(getDocumentBase(),"snow.gif");
    baby = getImage(getDocumentBase(),"baby.gif");
    // inserting images into correct tree structure
    System.out.println("inserting images into tree: ");
    // inserting background images into tree structure
    BackgroundImageTree.insertImage(1,snow);
    // inserting players into tree structure
    PlayerImageTree.insertImage(1,baby);
    public void paint(Graphics g){
    System.out.println("Searching for selected Image");
    if((BackgroundImageTree.inorderTraversal(1)==null)&&(PlayerImageTree.inorderTraversal(1)==null)){
    System.out.println("There is no tree with the selected value in the trees");
    }else{
    g.drawImage(BackgroundImageTree.inorderTraversal(1),1,3,this);
    //g.drawImage(PlayerImageTree.inorderTraversal(1),55,150,this);
    import java.awt.*;
    import java.applet.Applet;
    class TreeNode {
    TreeNode left;
    Image data;
    TreeNode right;
    int value;
    public TreeNode(int weight,Image picture){
    left = right = null;
    value = weight;
    data = picture;
    public void insert(int v, Image newImage){
    if ( v< value){
    if (left ==null)
    left = new TreeNode(v,newImage);
    else
    left.insert(v,newImage);
    else if (v>value){
    if (right ==null)
    right = new TreeNode(v,newImage);
    else
    right.insert(v, newImage);
    public class Tree{
    private TreeNode root;
    public Tree() {
    root = null;
    public void insertImage(int value, Image newImage){
    if (root == null)
    root = new TreeNode(value,newImage);
    else
    root.insert(value,newImage);
    // in order search of tree.
    public Image inorderTraversal(int n)
    return(inorderHelper(root,n));
    private Image inorderHelper(TreeNode node, int n){
    Image temp = null;
    if (node == null)
    return null;
    if (node.value == n ){
    return(node.data);
    temp = inorderHelper(node.left,n);
    if (temp == null){
    temp = inorderHelper(node.right,n);
    return temp;
    }

    I can fix your problems
    1. You get an error here because you can only invoke the superclass's constructor in the subclass's constructor. It looks like that's what you're trying to do, but you're not doing it right. Constructors don't return any value (actually they do, but it's implied, so you don't need the void that you've got in your code)
    2. I'm not sure, but I think your call to show might be wrong. Move the setsize and setvisible calls to outside of the constructor

  • Why does my ipad not work when powered up and screen just lights up dark blue?

    IPad Model A1219 does not respond when powered up, screen barely lights up just a dark blue screen thats it. will not do anything else, why?

    I think the subVI is working just fine when called from the main. I think what you're expecting is an indicator on the main VI to update as the subVI runs. What you will see on the main front panel is just the last value that a subVI has. That is the intended behavior of subVIs and function calls in all other languages. If you want to to update a front panel indicator while a subVI runs, pass a reference to the indicator into the subVI and update that reference instead of the indicator on the subVI. The other way is via a global variable. I've attached a modified version of your porgram.
    Attachments:
    Pass_a_Reference.vi ‏11 KB
    GL_Flicker_mod.vi ‏66 KB

  • Why does my .vi not work when used as a sub vi

    I have a vi that produces a picture on the front panel. Displayed in the picture are solid grey levels for testing. Two grey levels are chosen inside the vi and then the picture flickers betwen the two. When I run the vi by itself it runs wonderfully, but when I run it as a sub vi it does not work. Even when I just place the sub vi in the block diagram and connect all of the controls and indicators up it doesn't work.When I use the highlighter it shows that the control values go into the sub vi and the sub vi lights up, but there is nothing output from the sub vi to the wired indicators. When I open up the Block diagram of the original vi from which the sub vi came, and highlight it while running the subvi, it
    shows that it is working with information running to all of the indicators. If I start a new program with only the sub vi in the block diagram and all of the controls and indicators connected, should it not behave as the sub vi? I will attach the vi that I am using as a sub vi, and I welcome anyone to place it in the block diagram of a new vi, connect all of the controls and indicators up and see if it works. I know that there is something completely obviopus that I am missing, but I can't see it. Any help would be greatly appreciated.
    Attachments:
    GL_Flicker.vi ‏74 KB

    I think the subVI is working just fine when called from the main. I think what you're expecting is an indicator on the main VI to update as the subVI runs. What you will see on the main front panel is just the last value that a subVI has. That is the intended behavior of subVIs and function calls in all other languages. If you want to to update a front panel indicator while a subVI runs, pass a reference to the indicator into the subVI and update that reference instead of the indicator on the subVI. The other way is via a global variable. I've attached a modified version of your porgram.
    Attachments:
    Pass_a_Reference.vi ‏11 KB
    GL_Flicker_mod.vi ‏66 KB

  • Why does diadem intellisense not work when using scriptinclude or for global object

    I have a script with a different classes in it (scripted 1).  When I create an object of a class in the script 1 intellisense works.  Intellisense is when you type name of the object created from a class it shows all the possible variables and functions contained in that object.  But when I write another script and use scriptinclude(scripted 1) the intellisense does not work.  I also tried a global object and intesllisense does not work.  Is there a way to get intellisense to work when using scriptinclude?  I am working with version 2012. 

    Here is more information on the issue.
    I have a script with a different classes in it (scripted 1).  When I create an object of a class in the script 1 intellisense works.  Intellisense is when you type name of the object created from a class it shows all the possible variables and functions contained in that object.  But when I write another script and use scriptinclude(scripted 1) the intellisense does not work.  I also tried a global object and intesllisense does not work.  Is there a way to get intellisense to work when using scriptinclude?  I am working with version 2012. 
    'Test.vbs
    class test
        public function test1()
             msgbox("test1")
        end function
        public function test2()
             msgbox("test2")
        end function
    end class
    'now create a object of the class
    dim oTest
    set oTest=new Test
    'now when you type oTest. you get the following functions to choose from
    oTest.test1
            .test2
    Now if you remove the object from Test.vbs and create a main program with scriptinclude(Test.vbs) it will not show the two functions
    'Main.vbs
    Option Explicit  'Forces the explicit declaration of all the variables in a script.
    call scriptinclude("c:\1atmp\Test.vbs")
    dim oTest
    set oTest=new test
    'now when you type oTest. it shows none of the functions in the object oTest
    oTest.

  • Why does this expression not work as I'd hoped?

    I have a Black Solid 3 with a CC Particle World placed within it. I have some particles set up to run at 0.01 velocity outward from the center of my composition. I've put the following expression on the Velocity setting:
    value = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
    if (value > 50) 20 else 0.01
    The Audio Amplitude layer it is linked to is a auto-keyframe layer created from a .mp3 file - the values that it hits during the most intense part of the song range from 1 to around 85-90.
    Why does my velocity setting remain at 0.01 consistently, despite it being clearly evident that the Audio Amplitude layer is going far over 50.
    P.S.: If I change the > sign to a < sign, it stays at 20. Why?
    EDIT: Okay, it seems the issue was having the variable named as 'value'. Now that it works, it still doesn't seem to work as intended - I'd wanted the particles to move very slowly outward, and then whenever bass was detected, to speed up, until the bass was no longer detected, in which case it would return to a slow pace again, anyone have any idea how I'd go about doing this?
    Message was edited by: James Wingate

    One way is to prepare a "Remap Speed" slider somewhere in the comp that will control the remapping speed, and animate it.
    0 = time lock, 1 = normal speed, 2 = speedx2, etc
    Then in the time remap property of the layer, set this expression:
    s = [pickwhip the "Remap Speed" slider]
    t=inPoint;    // normal time
    T=inPoint;    // remapped time
    dt = thisComp.frameDuration;
    TIME = time-0.001;
    while (t<TIME){
        T+= s.valueAtTime(t) * dt;
        t+=dt;
    T;
    Ok i reread the original post again, in your case the "Remap Speed" slider could have the expression:
    value = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
    if (value > 50) 1 else 0.01          // above 50 : normal speed, under : very small speed

  • WHY DOES THIS SQL NOT WORK

    I have 4 statements.
    echo off
    plus80 / @z:\nesp1483_batch
    plus80 / @z:\nesp1484a_batch
    exit
    The first statement plus80 / @z:\nesp1484_batch inserts records into a table and creates a report and deletes the table.
    However the second statement plus80 / @z:\nesp1484a_batch is not working properly. I want it to insert records into a table, create a report and then delete the table but it is not working properly. It is hanging up on this statement.
    I need to say plus80 to get the program to execute properly.
    I have also tried sqlplus /@z:\nesp1484a_batch but this does not work either.
    What do I need to do to make the third statement to execute properly?

    I know that it is not working
    because the response time is slow and I have over 15 minutes
    and nothing is happening. How do you know it is not working as opposed to just working slow?
    Do you have any logging routines in your code? If you have, switch on them on and see what's happening. If not, now is a good time to think about including them...
    Cheers, APC

  • Chart timestamp accelerating - why does this VI not work?

    In fighting with TDMS files, I decided to experiment with a different approach to get what I need - a stripchart with a long history, that I can pause and scroll back through to look for anomolies.  Came up with a clever (I thought) approach to it...  Not the most elegant, but it should work.  In the attached VI, I have 2 charts simulating my data on the left, and 2 charts that will be my scrollable history on the right.  I worked out how to apply a correct timestamp to the charts, and am basically just passing the history from the source chart to the history one - unless the "pause" button is on, which allows me to scroll back.  All of the charts are set with a window of 300 points, and the VI cycles at 200ms, so it should be a 1 minute active window before it scrolls off the edge and into the buffer.  The chart buffer size is set for 180000 for each chart, which should be 10 hours of data at this polling rate.
    I start the program, everything is fine.  Both sets of charts begin populating, the timestamp is chugging away in 1 second intervals, it looks beautiful.  Then it all falls apart.  Once the chart is full, and begins scrolling, the timestamp goes nuts and begins accelerating.  It takes exactly 1 minute to fill the chart from empty, then the timestamp starts flying much faster - at least twice the speed, as the data being collected (and the actual time elapsed).  I haven't been able to determine if it is a set multiplier in speed, or if it is ramping up faster and faster.
    So...  How is this possible?  I can't see what the code could be doing to cause this.  It's so very frustrating, because the pause and scroll feature works perfectly, just like I planned it.  But without an accurate timestamp, this is completely useless.
    Edit - oops, attached old version of VI, updated with correct one now.
    Attachments:
    Advanced Chart with Timestamp.vi ‏30 KB

    I didn't run the code, but it sounds like this - http://lavag.org/topic/16789-chart-scale-falling-out-of-sync-with-data-grid/ . You can check if he found a solution.
    Personally, I tend to use XY graphs because they allow more control and don't require a single dx for all points. They are more of a pain because you have to buffer the data yourself, but the code for that is reasonably easy and I believe there's an XY chart example in the example finder.
    Try to take over the world!

  • Why does this code not work?

    String answer = new String("");
    in = new BufferedReader(new InputStreamReader( connection.getInputStream ()));
    String test = new String("");
    for (int i = 0 ; i < 1000 ; i++)
    answer = in.readLine();
    if (answer == null)
    System.out.println ("null");
    break;
    else
    test += answer;
    System.out.println ("answer: " + answer);
    System.out.println ("test: " + test);
    Many times, the loop will go through 2 iterations but each time, test is only equal to the first answer. The second, third, fourth etc.time it goes through the loop, it should concatenate the value of answer to the end of the string variable test. So why is it that whenever i run the program that has this code, the loop might lloop many times (let's say 2 time) but the value of test is only the first answer, and not the first answer concatenated with the second answer.

    It worked for me...my code looks like this...i used FileInputStream instead of connection..
    import java.io.*;
    class Forum {
      public static void main(String a[]) throws IOException{
        String answer = new String("");
        BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream("hi.txt")));
        String test = new String("");
        for (int i = 0 ; i < 1000 ; i++)
        answer = in.readLine();
        if (answer == null)
        System.out.println ("null");
        break;
        else
        test += answer;
        System.out.println ("answer: " + answer);
        System.out.println ("test: " + test);
    my hi.txt is like this:
    fasd rea reks krie
    fsdfasd
    asdfasd
    sfasdf
    asdfasd
    The output is
    answer: fasd rea reks krie
    answer: fsdfasd
    answer: asdfasd
    answer: sfasdf
    answer: asdfasd
    null
    test: fasd rea reks kriefsdfasdasdfasdsfasdfasdfasd
    Is this not the way u want???

  • Why does this program not stop when not highlighted.

    When I highlight the execution of this program it runs through and stops. However when I take off the highlight then the program does not quit running. I have encountered this problem on other programs as well. What causes it?
    Attachments:
    isotonic.vi ‏180 KB

    Hello,
    Thank you for contacting National Instruments.
    I took a look at your VI. I think the problem may be that you are using a Continue if True loop condition in your first While Loop. If you press the stop button wired to this condition or if an error is generated in your VI, that first loop will continue to run indefinitely. Try right clicking the loop conditional and changing it to Stop if True. You may then need to change your Less? function to a Greater? function within that same loop to preserve the intended behavior of your program
    I hope this solves your problem. If not, let me know.
    Matthew C
    Applications Engineer
    National Instruments

  • Why does my cursor not work when hovering in certain sites?

    My cursor does not bring up information when i hover in sites like appointment plus. I use safari, when i downloaded firefox and signed on the cursor worked, is there something i am missing? I prefer safari, but will switch to firefox if i have to.
    At my office i have an old mac with snow leopard and the cursor works on that while on safari. my home computer has lion and it doesn't work

    Your Mac sends traffic to the interface at the top of the list in
    System Preferences > Network
    When you plug in the second Ethernet, that Interface jumps to the top of the list and all traffic goes there.
    The solution is to cable that Printer to your Router, not to your Mac.
    Alternatively, you could add a small Switch and connect your Mac and the printer to it.
    If you really want to you can use Internet Sharing to add the Ethernet port going to the Printer to the Network connacted to the Internet.

Maybe you are looking for