Professional Web Applications Themes

"Open" shell command not working in StartupItems - Mac Programming

The "test_script" is build from Standard Tool project in Xcode. This tool fork and the child process execl the shell script "shell_script_test" below. !/bin/sh echo `date` >> /Users/alain/Desktop/file_test open -e /Users/alain/Desktop/shell_script_test When the tool "test_script" is called from the Terminal, "file_test" is updated with the right date and TextEdit is launched (with the text of "shell_script_test"). But when the tool "test_script" is called by the SystemStarter (in /Library/StartupItems/test_script/test_script) "file_test" is updated with the right date but TextEdit is never launched. Building "test_script" as Fondation, CoreDervices or CoreFondation Tool doesn't change anything. The code for "test_script" is below. Since it is ...

  1. #1

    Default "Open" shell command not working in StartupItems

    The "test_script" is build from Standard Tool project in Xcode.
    This tool fork and the child process execl the shell script
    "shell_script_test" below.

    !/bin/sh

    echo `date` >> /Users/alain/Desktop/file_test
    open -e /Users/alain/Desktop/shell_script_test

    When the tool "test_script" is called from the Terminal, "file_test"
    is updated with the right date and TextEdit is launched (with the text of
    "shell_script_test").

    But when the tool "test_script" is called by the SystemStarter (in
    /Library/StartupItems/test_script/test_script)
    "file_test" is updated with the right date but TextEdit is never launched.

    Building "test_script" as Fondation, CoreDervices or CoreFondation Tool
    doesn't change anything.

    The code for "test_script" is below.

    Since it is the same tool, why TextEdit is launched from Terminal but not
    from StartupItems ?
    (the tool is called since "file_test" is updated)
    Changing environment variables and/or files permission seem does not
    change anything.

    Any suggestion will be greatly appreciate...



    #include <CoreFoundation/CoreFoundation.h>

    #include <unistd.h>

    void test();

    static char script_name[] = "/Users/alain/Desktop/shell_script_test";

    int main (int argc, const char * argv[])
    {

    test();

    // CFShow(CFSTR("Hello, World!\n"));
    return 0;
    }

    void test()
    {
    int err;
    pid_t ret;

    ret = fork();
    switch (ret)
    {
    case -1:
    break;
    case 0:
    // sleep(60);
    err = execl(script_name, script_name, NULL);
    break;
    default:
    break;
    }
    }
    Alain Guest

  2. #2

    Default Re: "Open" shell command not working in StartupItems

    On Mon, 8 Dec 2003, Alain Birtz wrote:
     

    I'd guess that there needs to be a user logged in at the console.

    Fred

     

    Frederick Guest

  3. #3

    Default Re: "Open" shell command not working in StartupItems

    In article <168.1.100>,
    ca (Alain Birtz) wrote:
     

    Because "open" is designed to be the command-line equivalent of
    double-clicking on something in the Finder. It cannot work unless a
    user is logged in and running the Finder.

    --
    Tom "Tom" Harrington
    Macaroni, Automated System Maintenance for Mac OS X.
    Version 1.4: Best cleanup yet, gets files other tools miss.
    See http://www.atomicbird.com/
    Tom Guest

  4. #4

    Default Re: "Open" shell command not working in StartupItems

    But the same code work perfectly in Jaguar. "open" launch TextEdit
    at startup. The problem is new with Panther. Panther seem have changed
    the way "open" work...

    How to open an application like Login items at startup ?

    Is it possible to send an AppleEvent from Standard, Fondation,
    CoreDervices or CoreFondation Tool at startup ?


    In article <tph-F056A6.09482208122003localhost>, Tom Harrington
    <no.spam.dammit.net> wrote:
     
    >
    > Because "open" is designed to be the command-line equivalent of
    > double-clicking on something in the Finder. It cannot work unless a
    > user is logged in and running the Finder.[/ref]
    Alain Guest

  5. #5

    Default Re: "Open" shell command not working in StartupItems

    In article <168.1.100>,
    ca (Alain Birtz) wrote:
     

    How did it work in Jaguar? When the Mac boots, nobody is logged in at
    first. Where did TextEdit open? Is it possible that when you were
    using Jaguar, you had an account log in automatically, and you don't do
    this now?

    --
    Tom "Tom" Harrington
    Macaroni, Automated System Maintenance for Mac OS X.
    Version 1.4: Best cleanup yet, gets files other tools miss.
    See http://www.atomicbird.com/
    Tom Guest

  6. #6

    Default Re: "Open" shell command not working in StartupItems

    Yes I have an account (alain) that log in automatically.
    TextEdit open at this account.
    All running script and tool have user alain and group staff.

    But the alain account is the same in Panther and Jaguar,
    and permission, user and group are also the same.




    In article <tph-E868C4.13070109122003localhost>, Tom Harrington
    <no.spam.dammit.net> wrote:
     
    Alain Guest

  7. #7

    Default Re: "Open" shell command not working in StartupItems

    In article <168.1.100>,
    ca (Alain Birtz) wrote:
     

    TextEdit is a GUI tool: it presents a user-interface to the user
    and requires that user to be logged in so it can tell which
    display to show its user-interface on and which keyboard to take
    its keystrokes from. It also needs to know what permissions the
    user has so it can tell whether it should be able to read or
    write the files its working on. It also needs a user so it can
    tell which preference settings should be in effect.

    If there's no user, GUI applications won't work.


    Simon Guest

  8. #8

    Default Re: "Open" shell command not working in StartupItems

    In fact I build test_script to show that "open" doesn't work in the same
    way in Jaguar and Panther. For automatic login TextEdit is launched in
    Jaguar but not in Panther.

    In a larger project I will need to launch an application (like TextEdit)
    only after a keyboard action from the user (a long time after the startup
    process was closed).

    How to tell the system that "open" must work with the current user
    (the user who hit the keyboard) ?




    In article <0.1.2>,
    demon.co.uklocalhost (Simon Slavin) wrote:
     
    Alain Guest

  9. #9

    Default Re: "Open" shell command not working in StartupItems

    In article <168.1.100>,
    ca (Alain Birtz) wrote:
     

    It sounds like what you really want is a login item, not a startup item.

    --
    Tom "Tom" Harrington
    Macaroni, Automated System Maintenance for Mac OS X.
    Version 1.4: Best cleanup yet, gets files other tools miss.
    See http://www.atomicbird.com/
    Tom Guest

  10. #10

    Default Re: "Open" shell command not working in StartupItems (solved)

    Startup item like test_script come without PATH envvironment variable.
    Setting PATH as usual solve the problem.

    Thank you for all replies.


    In article <tph-54CF60.09305011122003localhost>, Tom Harrington
    <no.spam.dammit.net> wrote:
     
    >
    > It sounds like what you really want is a login item, not a startup item.[/ref]
    Alain Guest

Similar Threads

  1. FH9 file won't open "Unknown command.."
    By Dritalei in forum Macromedia Freehand
    Replies: 1
    Last Post: July 20th, 11:57 AM
  2. changing the default folder for the "open file" command
    By amiperl@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 0
    Last Post: April 26th, 05:16 PM
  3. Gretag Macbeth i1Match v2.0.3a update disables "Open" command for Photoshop files
    By Ray_Wenzel@adobeforums.com in forum Adobe Photoshop Mac CS, CS2 & CS3
    Replies: 0
    Last Post: April 13th, 03:06 PM
  4. Using the shell's "fmt" command in a perl script
    By Ranyart in forum PERL Miscellaneous
    Replies: 5
    Last Post: August 30th, 10:38 PM
  5. Replies: 5
    Last Post: July 28th, 06:26 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139