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 6181439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:01:27+00:00 2026-05-24T01:01:27+00:00

am using pexpect ssh to write down a script for compilation, the ssh automation

  • 0

am using pexpect ssh to write down a script for compilation, the ssh automation looks like this,

enter code here
child = ssh_expect('root', server2, cmd)
child.expect(pexpect.EOF)
print child.before

where cmd is this:

cmd = "./configure CFLAGS=\"-g -O0 -DDEBUG\""

the problem happens is that it says,

configure: error: unrecognized option: -O0

whereas, if run the same command using commands.getoutput then it executes properly.

Question what is the problem that this kind of error is getting generated and how can I erradicate this one?

thanks in advance 🙂

  • 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-05-24T01:01:27+00:00Added an answer on May 24, 2026 at 1:01 am

    The reason it’s working if you’re doing commands.getoutput is that all commands there are run though a shell, which will parse your commandline and understand that what’s between the double quotes after CFLAGS is part of the same parameter.

    When you’re running cmds through pexpect, no shell is involved. Also, there’s no shell involved on the other side of the ssh connection when you provide commands on the ssh commandline, so there’s nothing that parse CFLAGS into one parameter. Therefore, instead of the configure script getting one parameter (CFLAGS=\”-g -O0 -DDEBUG\”), it gets three parameters (‘CFLAGS=-g’, ‘-O0’, ‘-DDEBUG’).

    If possible, avoid sending commands where parameters are separated by spaces. It seems pexpect can take a list of arguments instead. Working code example:

    #/usr/bin/env python
    
    import pexpect
    
    def ssh_expect(user, hostname, cmd):
        child = pexpect.spawn("ssh", ["%s@%s" % (user, hostname)] + cmd, timeout=3600)
    
        return child
    
    child = ssh_expect("root", "server.example.com", ["./configure", "CFLAGS=\"-g -O0 -DDEBUG\""])
    child.expect(pexpect.EOF)
    print child.before
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
I am trying to test if a file exists over SSH using pexpect. I
I am trying to do ssh on a remote machine using a python script
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
I am trying to use pexpect to ssh into a computer but I do
How do I pass a certain key combination to a spawned/child process using the
I'm gathering some info from some cisco devices using python and pexpect, and had
Is there any way of writing pexpect like small program which can launch a
using CodeIgniter normally one has to specify the controllers in the config/routes.php file. This

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.