Thread: Disable echo in Perl

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    167

    Disable echo in Perl

    I want do make a perl script that runs other scripts that compile parts of a project. And if i run with system another script it displayes the whole commands set that the script executes. I want to disable that echo (inhibate it or something like that) so only my script can display messages on the stdin.

    Thank you!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Can you post an example?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Generally, you redirect the output of "other commands" to /dev/null or NUL: [linux/windows respectively], or if you still want to save the output, redirect to a file. If you want to, you can also redirect stderr by "2>" or "2>&1" - the latter "combines" the stderr with stdout.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    Registered User
    Join Date
    Dec 2005
    Posts
    167
    Code:
    ...
    		my $status = system("generate2.bat");
        		if (($status >>=8) != 0) 
    		{
            		die "Failed to generate pp1.txt";
       		}
    ...
    this displays what the generate2.bat echoes. I don't want to see that. How can I stop it from printing? (I'm not allowed to modify the generate2.bat file)

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    As described above:
    Code:
    system("generate2.bat >> NUL:");
    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Registered User
    Join Date
    Dec 2005
    Posts
    167
    now it gives me

    Code:
    sh: generate2.bat: command not found

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  2. A breakthrough
    By loopy in forum Linux Programming
    Replies: 4
    Last Post: 11-26-2003, 06:46 PM
  3. C-Shell Scripting.. Help!
    By denizengt in forum Tech Board
    Replies: 3
    Last Post: 10-29-2003, 01:37 PM
  4. perl need help pls.....
    By magnum38 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 12-12-2001, 10:35 PM
  5. echo command
    By Billing in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 08-31-2001, 08:38 PM