FAQ
I have the following command that redirects output from the script to
temp.txt.

system "ssh -x -t $_ \"sudo /home/tadipah/test.sh\" > temp.txt ";

If I open the file temp.txt, I can see one word "jboss"; I tried to print
it using the code below:

open TESTFILE, "temp.txt";
@srv=<TESTFILE>; chomp(@srv);
print "@srv \n";

All i get is " boss" . It is replacing the first charecter with a space
for some reason. Then I further tried creating my own text file names
temp.txt with jboss as its content. To my surprise, it printed "jboss"
this time.

So, I did a further research on the type of file the script is
automatically redirecting to as compared to the file I have created. Here
is the output:

tadipah@nhpljt007:~/THI/scripts> file temp.txt
temp.txt: ASCII text, with CRLF line terminators

tadipah@nhpljt007:~/THI/scripts> file temp.txt
temp.txt: ASCII text

So clearly, the file format made the differrence. Can someone please help
me how to combat this situation. I want automatic redirect of my shell
script to work normally.

Thanks,
Hary

Search Discussions

  • Ryan at Aug 27, 2008 at 6:44 pm
    given:

    sub really_long_function_name_i_do_not_like_to_type {return 'data';}

    can I create some kind of alias, like real_long_func ?

    how?
  • Rob Coops at Aug 27, 2008 at 7:00 pm
    Of course you can...

    sub really_long_function_name_i_do_not_like_to_type {return 'data';}

    sub short_func { return really_long_function_name_i_do_not_like_to_type(); }

    Should do the trick,

    Rob
    On Wed, Aug 27, 2008 at 8:44 PM, Ryan wrote:

    given:

    sub really_long_function_name_i_do_not_like_to_type {return 'data';}

    can I create some kind of alias, like real_long_func ?

    how?

    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
    http://learn.perl.org/

  • John W. Krahn at Aug 27, 2008 at 7:02 pm

    Ryan wrote:
    given:

    sub really_long_function_name_i_do_not_like_to_type {return 'data';}

    can I create some kind of alias, like real_long_func ?

    how?
    Using a typeglob copy:

    $ perl -le'
    sub really_long_function_name_i_do_not_like_to_type { return q/data/ }
    print really_long_function_name_i_do_not_like_to_type();
    *real_long_func = *really_long_function_name_i_do_not_like_to_type;
    print real_long_func();
    '
    data
    data


    Or use goto:

    $ perl -le'
    sub really_long_function_name_i_do_not_like_to_type { return q/data/ }
    print really_long_function_name_i_do_not_like_to_type();
    sub real_long_func { goto &really_long_function_name_i_do_not_like_to_type }
    print real_long_func();
    '
    data
    data



    John
    --
    Perl isn't a toolbox, but a small machine shop where you
    can special-order certain sorts of tools at low cost and
    in short order. -- Larry Wall
  • Raja Vadlamudi at Aug 27, 2008 at 7:19 pm
    Or you might just want to use typeglob for only sub-routine.

    *real_long_fund = \& really_long_function_name_i_do_not_like_to_type;

    On 8/27/08 3:02 PM, "John W. Krahn" wrote:

    Ryan wrote:
    given:

    sub really_long_function_name_i_do_not_like_to_type {return 'data';}

    can I create some kind of alias, like real_long_func ?

    how?
    Using a typeglob copy:

    $ perl -le'
    sub really_long_function_name_i_do_not_like_to_type { return q/data/ }
    print really_long_function_name_i_do_not_like_to_type();
    *real_long_func = *really_long_function_name_i_do_not_like_to_type;
    print real_long_func();
    '
    data
    data


    Or use goto:

    $ perl -le'
    sub really_long_function_name_i_do_not_like_to_type { return q/data/ }
    print really_long_function_name_i_do_not_like_to_type();
    sub real_long_func { goto &really_long_function_name_i_do_not_like_to_type }
    print real_long_func();
    '
    data
    data



    John
  • John W. Krahn at Aug 27, 2008 at 8:40 pm
    [ Please do not top-post. TIA ]

    Raja Vadlamudi wrote:
    On 8/27/08 3:02 PM, "John W. Krahn" wrote:

    Ryan wrote:
    sub really_long_function_name_i_do_not_like_to_type {return 'data';}

    can I create some kind of alias, like real_long_func ?
    Using a typeglob copy:

    $ perl -le'
    sub really_long_function_name_i_do_not_like_to_type { return q/data/ }
    print really_long_function_name_i_do_not_like_to_type();
    *real_long_func = *really_long_function_name_i_do_not_like_to_type;
    print real_long_func();
    '
    data
    data

    Or use goto:

    $ perl -le'
    sub really_long_function_name_i_do_not_like_to_type { return q/data/ }
    print really_long_function_name_i_do_not_like_to_type();
    sub real_long_func { goto &really_long_function_name_i_do_not_like_to_type }
    print real_long_func();
    '
    data
    data
    Or you might just want to use typeglob for only sub-routine.

    *real_long_fund = \& really_long_function_name_i_do_not_like_to_type;
    Or:

    *real_long_fund = *really_long_function_name_i_do_not_like_to_type{ CODE };



    John
    --
    Perl isn't a toolbox, but a small machine shop where you
    can special-order certain sorts of tools at low cost and
    in short order. -- Larry Wall

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedAug 27, '08 at 6:32p
activeAug 27, '08 at 8:40p
posts6
users5
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase