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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:54:32+00:00 2026-06-10T02:54:32+00:00

I am attempting to create a Python script that in turn runs the shell

  • 0

I am attempting to create a Python script that in turn runs the shell script “js2coffee” to convert some javascript into coffeescript.

From the command line I can run this, and get coffeescript back again…

echo "var myNumber = 100;" | js2coffee

What I need to do is use this same pattern from Python.

In Python, I’ve come to something like this:

command = "echo '" + myJavscript + "' | js2coffee"
result = os.popen(command).read()

This works sometimes, but there are issues related to special characters (mostly quotes, I think) not being properly escaped in the myJavascript. There has got to be a standard way of doing this. Any ideas? Thanks!

  • 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-10T02:54:33+00:00Added an answer on June 10, 2026 at 2:54 am

    Use the input stream of a process to feed it the data, that way you can avoid the shell and you don’t need to escape your javascript. Additionally, you’re not vulnerable to shell injection attacks;

    pr = subprocess.Popen(['js2coffee'], 
                          stdin=subprocess.PIPE,  
                          stdout=subprocess.PIPE)
    result, stderrdata = pr.communicate('var myNumber = 100;')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to create python bindings for some C++ code using swig. I
I'm attempting to create a custom calendar control that inherits from ASP.Net's built in
I'm having some difficulty attempting to create an SSL socket in Python to use
I'm attempting to convert a C header into a Python library using ctypes and
I'm attempting to create a table for monitoring purposes using the following script: $w3wppriv
I am attempting to create a report, utilizing a matrix, that only displays columns
I'm attempting to create a single Controller class to handle all foreseeable surveys that
I'm attempting to create a linked list of length n using Python. I have
Suppose I need to create my own small DSL that would use Python to
I am attempting to create an html document parser with Python. I am very

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.