Welcome to Soft32 Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

"Open" shell command not working in StartupItems

 
   Soft32 Home -> Mac -> Programmer Help RSS
Next:  ? prebinding message in Console  
Author Message
Alain Birtz

External


Since: Oct 27, 2003
Posts: 84



(Msg. 1) Posted: Mon Dec 08, 2003 4:14 am
Post subject: "Open" shell command not working in StartupItems
Archived from groups: comp>sys>mac>programmer>help (more info?)

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;
}
}
Back to top
Login to vote
Tom Harrington

External


Since: Aug 19, 2003
Posts: 1921



(Msg. 2) Posted: Mon Dec 08, 2003 4:14 am
Post subject: Re: "Open" shell command not working in StartupItems [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <abz-0812031014450001.DeleteThis@192.168.1.100>,
abz.DeleteThis@videotron.ca (Alain Birtz) wrote:

> 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 ?

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/
Back to top
Login to vote
Frederick Cheung

External


Since: Aug 23, 2003
Posts: 275



(Msg. 3) Posted: Mon Dec 08, 2003 9:51 am
Post subject: Re: "Open" shell command not working in StartupItems [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mon, 8 Dec 2003, Alain Birtz wrote:

> 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.

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

Fred


>
> 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;
> }
> }
>
Back to top
Login to vote
Tom Harrington

External


Since: Aug 19, 2003
Posts: 1921



(Msg. 4) Posted: Tue Dec 09, 2003 7:07 am
Post subject: Re: "Open" shell command not working in StartupItems [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <abz-0912031424000001 RemoveThis @192.168.1.100>,
abz RemoveThis @videotron.ca (Alain Birtz) wrote:

> 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 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/
Back to top
Login to vote
Simon Slavin

External


Since: Oct 10, 2003
Posts: 232



(Msg. 5) Posted: Wed Dec 10, 2003 7:31 pm
Post subject: Re: "Open" shell command not working in StartupItems [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <abz-0812031014450001.TakeThisOut@192.168.1.100>,
abz.TakeThisOut@videotron.ca (Alain Birtz) wrote:

>Since it is the same tool, why TextEdit is launched from Terminal but not
>from StartupItems ?

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.
Back to top
Login to vote
Alain Birtz

External


Since: Oct 27, 2003
Posts: 84



(Msg. 6) Posted: Thu Dec 11, 2003 12:49 am
Post subject: Re: "Open" shell command not working in StartupItems [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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 <BBFD7960966836BB71.TakeThisOut@10.0.1.2>,
slavins.TakeThisOut@hearsay.demon.co.uk@localhost (Simon Slavin) 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.
Back to top
Login to vote
Tom Harrington

External


Since: Aug 19, 2003
Posts: 1921



(Msg. 7) Posted: Thu Dec 11, 2003 3:30 am
Post subject: Re: "Open" shell command not working in StartupItems [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <abz-1112030649420001 DeleteThis @192.168.1.100>,
abz DeleteThis @videotron.ca (Alain Birtz) wrote:

> 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) ?

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/
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Timers in shell scripts - I'm looking for a way to log the elapsed time in some shell scripts. I know there is the timer command that will time...

shell script copies folders, but not files - Hello, A predecessor of mine wrote the following script to back up a user's local documents folder to the server: #!/...

Command-Option-D - Hello out there, In our application we have Command-Option-D assigned to a menu command. In Mac OS 10.1, our applicat...

How to run a command line tool? - Hi, A few of the Apple code examples build command line tools rather than proper apps. How do you 'run' these apps? I...

How to get the command line tool directory (written in C) - How to get the path of the command line tool programaticaly ? (after the command line tool was called from the Terminal...

Command line compiler arguments to build a framework? - What arguments do I need to pass the command line compiler in order to build a file as a framework?
       Soft32 Home -> Mac -> Programmer Help All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum

Categories:
 Windows
 Linux
  Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]