Discussion:
Commands executed via "system" runs twice
(too old to reply)
mlfedv
2006-07-24 08:18:56 UTC
Permalink
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 ***@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
Guenter
2006-07-24 08:41:58 UTC
Permalink
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.
Post by mlfedv
Hi Developers,
i have a NetWare 6.5 Box with SP5a.
____________________________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";
}
____________________________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
mlfedv
2006-07-24 12:02:52 UTC
Permalink
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
Post by Guenter
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.
Post by mlfedv
Hi Developers,
i have a NetWare 6.5 Box with SP5a.
____________________________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";
}
____________________________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
Guenter
2006-07-24 19:50:31 UTC
Permalink
Hi Manfred,
do you run the script from console, or from bash?

Guenter.
Post by mlfedv
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
Post by Guenter
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.
Post by mlfedv
Hi Developers,
i have a NetWare 6.5 Box with SP5a.
____________________________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";
}
____________________________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
mlfedv
2006-07-27 09:20:23 UTC
Permalink
Post by Guenter
Hi Manfred,
do you run the script from console, or from bash?
Guenter.
Post by mlfedv
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
Post by Guenter
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.
Post by mlfedv
Hi Developers,
i have a NetWare 6.5 Box with SP5a.
____________________________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";
}
____________________________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
mlfedv
2006-07-27 09:22:16 UTC
Permalink
Hi Guenter,

the command is executed via cronjob:
the command issued is
perl scriptname.pl --noscreen

thanks again
Manfred
Post by Guenter
Hi Manfred,
do you run the script from console, or from bash?
Guenter.
Post by mlfedv
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
Post by Guenter
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.
Post by mlfedv
Hi Developers,
i have a NetWare 6.5 Box with SP5a.
____________________________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";
}
____________________________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
Continue reading on narkive:
Loading...