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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:41:55+00:00 2026-06-12T06:41:55+00:00

I am trying to run a command through Python’s subprocess, but it won’t run

  • 0

I am trying to run a command through Python’s subprocess, but it won’t run properly. If I type into the shell:

pack < packfile.dat

where pack is my software and packfile is the input file, then the software runs fine.

If I try this in python:

import subprocess as sp
import shlex

cmd = 'pack < packfile.dat'.split()
p = sp.Popen(cmd)

The software complains:

Pack must be run with: pack < inputfile.inp 

Reading input file... (Control-C aborts)

and it hangs there.

This last part is specific to my software, but the fact is that the two methods of running the same command give different results, when this shouldn’t be the case.

Can anyone tell me what I’m doing wrong?

Actually, I intend to eventually do:

p = sp.Popen(cmd,stdout=sp.PIPE,stderr=sp.PIPE)
stdout, stderr = p.communicate()

Since I am a little new to this, if this is not best-practice, please let me know.

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-06-12T06:41:56+00:00Added an answer on June 12, 2026 at 6:41 am

    “<” isn’t a parameter to the command, and shouldn’t be passed as one.

    Try:

    p = sp.Popen(cmd,stdout=sp.PIPE,stderr=sp.PIPE, stdin=open('packfile.dat'))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to execute a command through C#, but when I run the
I'm trying to run a shell command from within a python script which needs
I am trying to run this shell script command through applescript on my mac
I'm trying to run a command line argument through VB.NET using the Shell() command.
I am trying to run grep command from my Python module using the subprocess
I am trying to run group command via mongo shell db.contract.group({ key:{id: 1}, initial:
Trying to run Jison unit tests, but the command fails. How do I fix
I am trying to run a script through command prompt in PHP and trying
I am trying to run a Python program using PHP. Here's the code $command
I'm trying to run an interactive command through paramiko. The cmd execution tries to

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.