Strange Output

From: Mallik (mkodiche_at_cisco.com)
Date: 12/24/04


To: <beginners@perl.org>
Date: Fri, 24 Dec 2004 12:06:00 +0530

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.



Relevant Pages

  • Re: file security with anonymous log in
    ... set the authorization token (and possible redirect to original ... authentication/authorization scheme, and you haven't written all of the ... If the path to the xls file is known, IUSER can execute via the URL, ...
    (microsoft.public.inetserver.misc)
  • Re: Question Multi A/V Tool
    ... You have to execute NET START WORKSTATION in a Command Prompt. ... What I get in the Command Prompt window is that the service has already been ...
    (microsoft.public.security.virus)
  • DWMX comes up for .net executable
    ... Then went to the console (command ... Well when I go to execute the program Dreamweaver opens up in the code ... of the picture and my program to execute through the command prompt ...
    (microsoft.public.vsnet.setup)
  • Re: Running a program from a SQL job
    ... This works fine when running it either as a bat file or just in a cmd ... When I set the SQL job to execute the same bat ... >> command prompt in the background which SQL apparently doesn't do. ... >> command prompt and then execute a program from there. ...
    (microsoft.public.sqlserver.server)
  • Re: Cant CreateProcess from custom shell
    ... I can't execute ... > from the command prompt as I am running my own custom shell. ... I include "CMD- Windows Command Processor" in my images ...
    (microsoft.public.windowsxp.embedded)