This widget could not be displayed.
Operating System - HP-UX
1845517 Members
3899 Online
110244 Solutions
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
New Discussion
This widget could not be displayed.
This widget could not be displayed.

Perl to send cntl c and cntl d

 
Ratzie
Super Advisor

Perl to send cntl c and cntl d

I am using the telnet module in perl to telnet to a switch
The funky thing about this switch is that I need to send a cntrl D to get a prompt, then I type a command, and to send the command I need to type a control C.
How do I incorporate this in my script.
Or convert it to actual control characters.
I thought there was a way to do this in vi...
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor

Re: Perl to send cntl c and cntl d

Hi:

You can generate a Ctrl_C with "\003" and Ctrl_D with "\004".

# echo "\003" | cat -etv

# perl -e 'print "\003"' | cat -etv

If you want to create these characters in a 'vi' session, type Ctrl_v and then press either Ctrl_C or Ctrl_D. See the 'ascii(5)' manpages for more information.

Regards!

...JRF...
Regards!

...JRF...
H.Merijn Brand (procura
Honored Contributor

Re: Perl to send cntl c and cntl d

perl does have a much nicer way to write that:

# perl -le 'print "\cC\cD"'

# perl -le 'print "\cC\cD"' | perl -nle'print join " ", unpack"C*",$_'
3 4
#

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Ratzie
Super Advisor

Re: Perl to send cntl c and cntl d

I have taken the low road and went with a quick expect script called by perl