Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9019945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:53:25+00:00 2026-06-16T04:53:25+00:00

I have an expect script that is logging into a pfSense/BSD box over SSH,

  • 0

I have an expect script that is logging into a pfSense/BSD box over SSH, it’s called by a Perl script and passes the output back to the Perl script (a RANCID plugin).

Currently I am getting the following output;

+ spawn ssh -2 -x -l rancid my-pfsense-device.fqdn.com
+ Password:
+ Last login: Wed Dec 19 10:28:47 2012 from 89.21.224.35
+ Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
+       The Regents of the University of California.  All rights reserved.
+
+
+  [0;1;33m[ [0;1;37m2.0.1-RELEASE [0;1;33m] [0;1;33m[ [0;1;37mrancid [0;1;31m@ [0;1;37mmy-pfsense-device.fqdn.com [0;1;33m] [0;1;32m/home/rancid [0;1;33m( [0;1;37m1 [0;1;33m) [0;1;36m [0;1;31m: [0;40;37m
uname -a
+ FreeBSD my-pfsense-device.fqdn.com 8.1-RELEASE-p6 FreeBSD
8.1-RELEASE-p6 #0: Mon Dec 12 18:59:41 EST 2011
root@FreeBSD_8.0_pfSense_2.0-snaps.pfsense.org:/usr/obj./usr/pfSensesrc/src/sys/pfSense_wrap.8.i386
 i386
+  [0;1;33m[ [0;1;37m2.0.1-RELEASE [0;1;33m] [0;1;33m[ [0;1;37mrancid [0;1;31m@ [0;1;37mmy-pfsense-device.fqdn.com [0;1;33m] [0;1;32m/home/rancid [0;1;33m( [0;1;37m2 [0;1;33m) [0;1;36m [0;1;31m: [0;40;37m
cat /cf/conf/config.xml
+ <?xml version="1.0"?>
+ <pfsense>

The problem here is that the login prompt looks like this when logged in via SSH from my desktop;

[2.0.1-RELEASE][username@my-pfsense-device.fqdn.com]/home/username(1):

But this is in a variety of colours. As you can see in the output above, SSH is being passed all the colouring information, which then gets output to my expect script. The same line looks like this in the above output;

[0;1;33m[ [0;1;37m2.0.1-RELEASE [0;1;33m] [0;1;33m[ [0;1;37musername [0;1;31m@ [0;1;37mmy-pfsense-device.fqdn.com [0;1;33m] [0;1;32m/home/username [0;1;33m( [0;1;37m1 [0;1;33m) [0;1;36m [0;1;31m: [0;40;37m

Is there a way I can script this off? Is it a standard colour format that and be regex’ed out, or perhaps I need to change an option on my SSH client to ignore colouring info?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:53:26+00:00Added an answer on June 16, 2026 at 4:53 am

    Whether or not a terminal can display colors is determined by the TERM environment variable. It’s usually set to something like xterm, linux or screen (maybe with a -256color postfix for even more goodness). Hopefully the shell (and more importantly: the shell initialization scripts) on the other side pay attention to TERM and only try to use color if the terminal on the caller’s side actually supports colors.

    You can try setting that variable right before your call to ssh. The usual value to set it to for “terminal with no interactive and no color capabilities” is dumb.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a expect script that need to fail when certain any of the
I have a perl script that writes out an array filled with integers to
I have an expect file that looks like this. I invoke the script using
I have a script that produces a lot of output. The script pauses for
I have a perl script that receives 3 arugments. First argument is very long
I'm pretty new to scripting in general. I'm writing an expect script that ssh'es
I have a perl script: #!/usr/bin/perl -w use DateTime; use Expect; use IO::Pty; use
Say I have two functions that expect ...rest parameters private function a(...myParams):void { trace(myParams.length);
If I have an element on a web page that I expect to be
I have the following bit of code, I expect that given cstdio is included

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.