Groups > Novell > Perl for NetWare > Re: Commands executed via "system" runs twice




Commands executed via "system" runs twice

Commands executed via "system" runs twice
Mon, 24 Jul 2006 08:18:56 GMT
Hi Developers,

i have a NetWare 6.5 Box with SP5a.

I'm running the following script:
____________________________Scriptstart
#!sys:/perl/bin/perl       
$quelle = "EXT:\INBOUND";
$ziel = "DATA:\INBOUND\";

if (-d $quelle) {
      $where = $quelle;
   } else {
      die("Verzeichnis $quelle existiert nicht!");
  }

while (defined($next = <$where/*.txt>)) {
   $datendatei = substr $next,0,(length $next)-4;
   system "copy $datendatei $ziel -rm";
   system "copy $next $ziel -rm";
   system "nwmail $next receiver@domain server from";
   }
____________________________Scriptend

The script looks at a directory if there is one or more Files ending with
.txt (we are getting data from outside, the .txt is simply a flag that the
datafile (same name without .txt) is completely copied).

If there is one(or more) .txt , it executes the copy command (from
toolbox).  

When i look at the loggerscreen, i see that every command is executed
twice!
Where is my mistake? 

Kind regards
Manfred Lapp-Friedrichs
MCNI

Post Reply
Re: Commands executed via "system" runs twice
Mon, 24 Jul 2006 08:41:58 GMT
Hi Manfred,
your script doesnt work this way. You should avoid the system() calls 
completely because you cant expect that they get executed one by one - the 
system() call only fires the command, and immediatly returns without 
waiting for completetion if the command - just same as the loader does from 
prompt. Since there are modules available for copying as well as mailing 
you should rewrite that.
If you need more help with this you can reach me at
http://www.gknw.de/phpbb

Guenter.

mailREMOVETHIS@ANDTHISmlf-edv.de (mlfedv) wrote in news:Qn%wg.2278$a27.1952
@prv-forum2.provo.novell.com:

> Hi Developers,
> 
> i have a NetWare 6.5 Box with SP5a.
> 
> I'm running the following script:
> ____________________________Scriptstart
> #!sys:/perl/bin/perl       
> $quelle = "EXT:\INBOUND";
> $ziel = "DATA:\INBOUND\";
> 
> if (-d $quelle) {
>       $where = $quelle;
>    } else {
>       die("Verzeichnis $quelle existiert nicht!");
>   }
> 
> while (defined($next = <$where/*.txt>)) {
>    $datendatei = substr $next,0,(length $next)-4;
>    system "copy $datendatei $ziel -rm";
>    system "copy $next $ziel -rm";
>    system "nwmail $next receiver@domain server from";
>    }
> ____________________________Scriptend
> 
> The script looks at a directory if there is one or more Files ending with
> txt (we are getting data from outside, the .txt is simply a flag that the
> datafile (same name without .txt) is completely copied).
> 
> If there is one(or more) .txt , it executes the copy command (from
> toolbox).  
> 
> When i look at the loggerscreen, i see that every command is executed
> twice!
> Where is my mistake? 
> 
> Kind regards
> Manfred Lapp-Friedrichs
> MCNI
> 
> 
> 
Post Reply
Re: Commands executed via "system" runs twice
Mon, 24 Jul 2006 12:02:52 GMT
Hi Guenter,

oh the script is doing fine so far, only the commands are getting executed
twice.
I'll rewrite the script with Module calls but there must be a reason for
double execution of system calls here. Is it a bug?

Maybe someone can tell my WHY this is happening. I really like to know
that so i can explain other students why they should use modules instead
of doing a system call.

Thank you very much for your reply anyway.

Manfred

Guenter wrote:

> Hi Manfred,
> your script doesnt work this way. You should avoid the system() calls 
> completely because you cant expect that they get executed one by one - the

> system() call only fires the command, and immediatly returns without 
> waiting for completetion if the command - just same as the loader does from

> prompt. Since there are modules available for copying as well as mailing 
> you should rewrite that.
> If you need more help with this you can reach me at
> http://www.gknw.de/phpbb

> Guenter.

> mailREMOVETHIS@ANDTHISmlf-edv.de (mlfedv) wrote in
news:Qn%wg.2278$a27.1952
> @prv-forum2.provo.novell.com:

> > Hi Developers,
> > 
> > i have a NetWare 6.5 Box with SP5a.
> > 
> > I'm running the following script:
> > ____________________________Scriptstart
> > #!sys:/perl/bin/perl       
> > $quelle = "EXT:INBOUND";
> > $ziel = "DATA:INBOUND";
> > 
> > if (-d $quelle) {
> >       $where = $quelle;
> >    } else {
> >       die("Verzeichnis $quelle existiert nicht!");
> >   }
> > 
> > while (defined($next = <$where/*.txt>)) {
> >    $datendatei = substr $next,0,(length $next)-4;
> >    system "copy $datendatei $ziel -rm";
> >    system "copy $next $ziel -rm";
> >    system "nwmail $next receiver@domain server from";
> >    }
> > ____________________________Scriptend
> > 
> > The script looks at a directory if there is one or more Files ending
with
> > txt (we are getting data from outside, the .txt is simply a flag that
the
> > datafile (same name without .txt) is completely copied).
> > 
> > If there is one(or more) .txt , it executes the copy command (from
> > toolbox).  
> > 
> > When i look at the loggerscreen, i see that every command is executed
> > twice!
> > Where is my mistake? 
> > 
> > Kind regards
> > Manfred Lapp-Friedrichs
> > MCNI
> > 
> > 
> >

Post Reply
Re: Commands executed via "system" runs twice
Mon, 24 Jul 2006 19:50:31 GMT
Hi Manfred,
do you run the script from console, or from bash?

Guenter.

mailREMOVETHIS@ANDTHISmlf-edv.de (mlfedv) wrote in
news:MF2xg.2342$a27.134@prv-forum2.provo.novell.com: 

> Hi Guenter,
> 
> oh the script is doing fine so far, only the commands are getting
> executed twice.
> I'll rewrite the script with Module calls but there must be a reason for
> double execution of system calls here. Is it a bug?
> 
> Maybe someone can tell my WHY this is happening. I really like to know
> that so i can explain other students why they should use modules instead
> of doing a system call.
> 
> Thank you very much for your reply anyway.
> 
> Manfred
> 
> Guenter wrote:
> 
>> Hi Manfred,
>> your script doesnt work this way. You should avoid the system() calls 
>> completely because you cant expect that they get executed one by one -
>> the system() call only fires the command, and immediatly returns
>> without waiting for completetion if the command - just same as the
>> loader does from prompt. Since there are modules available for copying
>> as well as mailing you should rewrite that.
>> If you need more help with this you can reach me at
>> http://www.gknw.de/phpbb
> 
>> Guenter.
> 
>> mailREMOVETHIS@ANDTHISmlf-edv.de (mlfedv) wrote in
>> news:Qn%wg.2278$a27.1952 @prv-forum2.provo.novell.com:
> 
>> > Hi Developers,
>> > 
>> > i have a NetWare 6.5 Box with SP5a.
>> > 
>> > I'm running the following script:
>> > ____________________________Scriptstart
>> > #!sys:/perl/bin/perl       
>> > $quelle = "EXT:INBOUND";
>> > $ziel = "DATA:INBOUND";
>> > 
>> > if (-d $quelle) {
>> >       $where = $quelle;
>> >    } else {
>> >       die("Verzeichnis $quelle existiert nicht!");
>> >   }
>> > 
>> > while (defined($next = <$where/*.txt>)) {
>> >    $datendatei = substr $next,0,(length $next)-4;
>> >    system "copy $datendatei $ziel -rm";
>> >    system "copy $next $ziel -rm";
>> >    system "nwmail $next receiver@domain server from";
>> >    }
>> > ____________________________Scriptend
>> > 
>> > The script looks at a directory if there is one or more Files
ending
>> > with txt (we are getting data from outside, the .txt is simply a
flag
>> > that the datafile (same name without .txt) is completely copied).
>> > 
>> > If there is one(or more) .txt , it executes the copy command
(from
>> > toolbox).  
>> > 
>> > When i look at the loggerscreen, i see that every command is
executed
>> > twice!
>> > Where is my mistake? 
>> > 
>> > Kind regards
>> > Manfred Lapp-Friedrichs
>> > MCNI
>> > 
>> > 
>> >
> 
> 
> 
Post Reply
Re: Commands executed via "system" runs twice
Thu, 27 Jul 2006 09:20:23 GMT
Guenter wrote:

> Hi Manfred,
> do you run the script from console, or from bash?

> Guenter.

> mailREMOVETHIS@ANDTHISmlf-edv.de (mlfedv) wrote in
> news:MF2xg.2342$a27.134@prv-forum2.provo.novell.com: 

> > Hi Guenter,
> > 
> > oh the script is doing fine so far, only the commands are getting
> > executed twice.
> > I'll rewrite the script with Module calls but there must be a reason
for
> > double execution of system calls here. Is it a bug?
> > 
> > Maybe someone can tell my WHY this is happening. I really like to
know
> > that so i can explain other students why they should use modules
instead
> > of doing a system call.
> > 
> > Thank you very much for your reply anyway.
> > 
> > Manfred
> > 
> > Guenter wrote:
> > 
> >> Hi Manfred,
> >> your script doesnt work this way. You should avoid the system()
calls 
> >> completely because you cant expect that they get executed one by
one -
> >> the system() call only fires the command, and immediatly returns
> >> without waiting for completetion if the command - just same as
the
> >> loader does from prompt. Since there are modules available for
copying
> >> as well as mailing you should rewrite that.
> >> If you need more help with this you can reach me at
> >> http://www.gknw.de/phpbb
> > 
> >> Guenter.
> > 
> >> mailREMOVETHIS@ANDTHISmlf-edv.de (mlfedv) wrote in
> >> news:Qn%wg.2278$a27.1952 @prv-forum2.provo.novell.com:
> > 
> >> > Hi Developers,
> >> > 
> >> > i have a NetWare 6.5 Box with SP5a.
> >> > 
> >> > I'm running the following script:
> >> > ____________________________Scriptstart
> >> > #!sys:/perl/bin/perl       
> >> > $quelle = "EXT:INBOUND";
> >> > $ziel = "DATA:INBOUND";
> >> > 
> >> > if (-d $quelle) {
> >> >       $where = $quelle;
> >> >    } else {
> >> >       die("Verzeichnis $quelle existiert nicht!");
> >> >   }
> >> > 
> >> > while (defined($next = <$where/*.txt>)) {
> >> >    $datendatei = substr $next,0,(length $next)-4;
> >> >    system "copy $datendatei $ziel -rm";
> >> >    system "copy $next $ziel -rm";
> >> >    system "nwmail $next receiver@domain server
from";
> >> >    }
> >> > ____________________________Scriptend
> >> > 
> >> > The script looks at a directory if there is one or more Files
ending
> >> > with txt (we are getting data from outside, the .txt is
simply a flag
> >> > that the datafile (same name without .txt) is completely
copied).
> >> > 
> >> > If there is one(or more) .txt , it executes the copy command
(from
> >> > toolbox).  
> >> > 
> >> > When i look at the loggerscreen, i see that every command is
executed
> >> > twice!
> >> > Where is my mistake? 
> >> > 
> >> > Kind regards
> >> > Manfred Lapp-Friedrichs
> >> > MCNI
> >> > 
> >> > 
> >> >
> > 
> > 
> >

Post Reply
<< Previous 1 2 Next >>
( Page 1 of 2 )
about | contact