Hi Friends,

I have the below code.

        #!/usr/local/perl5.6.1/bin/perl

        print STDOUT "===============================Before system
call===========================\n\n";
        system("ls -al");
        print STDOUT "\n\n===========================After System
Call============================\n\n";

When I execute the code from command prompt, the output is,


===============================Before system
call===========================

total 8
drwxr-xr-x   2 mkodiche cisco         96 Dec 23 21:54 .
drwxr-xr-x   4 mkodiche cisco       1024 Dec 23 19:36 ..
-rw-r--r--   1 mkodiche cisco        465 Dec 23 22:00 a.txt
-rwxrwxr-x   1 mkodiche cisco        279 Dec 23 22:00 background.pl
-rwxrwxr-x   1 mkodiche cisco         92 Dec 23 21:53 loop.pl


===========================After System Call============================


But, when I redirect the output to a file, the contents of the file are

total 6
drwxr-xr-x   2 mkodiche cisco         96 Dec 23 21:54 .
drwxr-xr-x   4 mkodiche cisco       1024 Dec 23 19:36 ..
-rw-r--r--   1 mkodiche cisco          0 Dec 23 22:34 a.txt
-rwxrwxr-x   1 mkodiche cisco        279 Dec 23 22:00 background.pl
-rwxrwxr-x   1 mkodiche cisco         92 Dec 23 21:53 loop.pl
===============================Before system
call===========================

===========================After System Call============================

As seen above, the system call output is displayed first and then the
print statement.

Why it is behaving strangely? Any idea?

Thanks is advance,

Mallik.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to