system() won't run shell script correctly 
Author Message
 system() won't run shell script correctly

This command executes correctly in a shell script:

xterm -e rlogin foo

The xterm comes up and lets me login to foo.
However, the same command in a Perl script does not:

system("xterm -e rlogin foo")

the xterm just flashes and goes away.

What gives?
Some kind of stty problem?

Please help if you know how this works.

-kin



Sat, 25 Mar 2000 03:00:00 GMT  
 system() won't run shell script correctly


Quote:

> > However, the same command in a Perl script does not:

> > system("xterm -e rlogin foo")

> > the xterm just flashes and goes away.
> The system command spawns a shell to run the command,

Wrong.  Sometimes it does, but not in the above case.

Ilya



Sat, 25 Mar 2000 03:00:00 GMT  
 system() won't run shell script correctly



Quote:
> This command executes correctly in a shell script:

> xterm -e rlogin foo

> The xterm comes up and lets me login to foo.
> However, the same command in a Perl script does not:

> system("xterm -e rlogin foo")

> the xterm just flashes and goes away.

> What gives?
> Some kind of stty problem?

> Please help if you know how this works.

Well, when you run the command from the shell, it runs the
command, without exiting, because it fork()s a copy of itself
and then exec(s) the command you asked for.

The system command spawns a shell to run the command, and then
the shell terminates, removing the foundation for the xterm
process, which dies of fright.

If your perl script is just a one liner to do this, then you
might do :-

exec("xterm -e rlogin foo");

which will cause your perl script to transform into the command
you want.

If you need your perl script to remain unmolested (and do other
things) then you need to fork() another process, and then have
the child run the exec() command.

Regards
Neil



Sat, 25 Mar 2000 03:00:00 GMT  
 system() won't run shell script correctly

Quote:



>> > However, the same command in a Perl script does not:

>> > system("xterm -e rlogin foo")

>> > the xterm just flashes and goes away.

>> The system command spawns a shell to run the command,

>Wrong.  Sometimes it does, but not in the above case.

I think the key issue is a spawned _process_, which is not necessarily a shell.
But what you are saying is that Perl makes a distinction between:

   system( "xterm -e rlogin foo" );

and

   system( "PATH=$PATH:/usr/bin/X11; xterm -e rlogin foo" );

Are you sure it makes this distinction?

Dave

|
| Please visit me at http://w3.one.net/~dlripber
|
| For reply by email, use:

|________



Sun, 26 Mar 2000 03:00:00 GMT  
 system() won't run shell script correctly

Quote:


> >> The system command spawns a shell to run the command,

> >Wrong.  Sometimes it does, but not in the above case.

> I think the key issue is a spawned _process_, which is not necessarily a shell.
> But what you are saying is that Perl makes a distinction between:

>    system( "xterm -e rlogin foo" );

> and

>    system( "PATH=$PATH:/usr/bin/X11; xterm -e rlogin foo" );

> Are you sure it makes this distinction?

Are you sure you've read the documentation?

Ilya



Sun, 26 Mar 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. perl script won't run correctly inside emacs

2. Please Help:My script runs on win32, it won't run on Unix

3. My script runs on win32, it won't run on Unix

4. Please Help: My script runs on win32, it won't run on Unix

5. script won't run...displays script text

6. Script runs fine from shell, but browser doesn't receive variables

7. perl 4 script that won't run under perl 5

8. why won't this short script run?

9. Perl CGI scripts won't run without -w switch (under Apache 1.3.x)

10. Perl scripts won't run on Linux

11. IIS4.0 won't run perl scripts which call external commands

12. Server won't run Perl scripts (Fasttrack)

 

 
Powered by phpBB® Forum Software