doubledecker has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks

I'm using Shell::Source to source .cshrc file in my perl script. Whilst doing so, it is printing some characters when i run the script. How can i suppress them without printing on the screen. Any help is appreciated.

use strict; use Shell::Source my $csh = Shell::Source->new(shell => "csh", file => "$ENV{Home}/.cshr +c"); $csh->inherit;

Replies are listed 'Best First'.
Re: Shell Source
by davido (Cardinal) on Jul 12, 2012 at 09:01 UTC

    Try running it within a Capture::Tiny compartment.

    use Capture::Tiny qw( capture ); use Shell::Source; my $csh; my( $stdout, $stderr, @result ) = capture { $csh = Shell::Source->new( shell => "csh", file => "$ENV{Home}/.cshrc" ); $csh->inherit; };

    (This is an untested suggestion.)


    Dave

Re: Shell Source
by Corion (Patriarch) on Jul 12, 2012 at 09:01 UTC

    What is the shell script source? If that shell script is printing stuff, maybe that's intended? I would make the commands in the sourced shell script silent.

    Have you looked at the documentation?

    Also, if you're just interested in setting up some environment variables, consider just using Get default login environment.

      when i manually source the file, it isn't printing anything on the console. I need to run .cshrc file to import all the environment variables in to my Perl script.
Re: Shell Source
by aitap (Curate) on Jul 12, 2012 at 11:02 UTC
    Can you show the example of .cshrc and characters perl prints while sourcing it?
    Sorry if my advice was wrong.
      \033]2;test_mac:kars: /home/kars/dev/links TEST_SQL\007\033]1test_mac\007