Hello all,

The code below is intended to change the prompt color in bash to red.
#!/usr/bin/perl use warnings; use strict; use IPC::Open3; $|=1; # set \*ERR to 0 to send STDERR to STDOUT my $pid=open3 (\*IN, \*OUT , 0, '/bin/bash' ); my $cmd = qq( export PS1="\e[0;31m[\u@\h \W]$ \e[m " ); print IN "$cmd\n"; # Send cmd to bash. my $result = <OUT>; print $result;
Below is the output of the script.
Unrecognized escape \h passed through at 11.pl line 12. Unrecognized escape \W passed through at 11.pl line 12. Use of uninitialized value in concatenation (.) or string at 11.pl lin +e 12.
Line 12 is the bash command to change the prompt to red. Also, it is hanging after I ran the script. What am I doing wrong here??

In reply to Send Bash Command by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.