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

  • SEARCH
  • Home
  • 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 9080013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:58:29+00:00 2026-06-16T19:58:29+00:00

I have two simple scripts – I am trying to pass some information (date

  • 0

I have two simple scripts – I am trying to pass some information (date as input into the python script) to the bash script. Here’s the python one:

#!/usr/local/bin/python

import os
import sys
import subprocess

year = "2012"
month = "5"
month_name = "may"

file = open('date.tmp','w')
file.write(year + "\n")
file.write(month + "\n")
file.write(month_name + "\n")
file.close

subprocess.call("/home/lukasz/bashdate.sh")

And here’s the bash one:

#!/bin/bash

cat /home/lukasz/date.tmp | \
while read CMD; do
    echo -e $CMD
done
rm /home/lukasz/date.tmp

Python script works fine without issues. It calls the bash script but it looks like the while loop just does not run. I know the bash script does run overall because the rm command gets executed and the date.tmp file is removed. However if I comment out the subprocess call in python then run the bash script manually it works fine displaying each line.

Brief explanation of what I am trying to accomplish. I have a python script that exports a very large DB to CSV (almost 300 tables and a few gigs of data) which then calls the bash script to zip the CSVs into one file and move it to another location. I need to pass the month and year supplied to the python script to the bash script.

  • 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-16T19:58:30+00:00Added an answer on June 16, 2026 at 7:58 pm

    Instead of writing a temp file, send the values of year, month, and month-name to the bash script as parameters. Ie, in the Python code remove all the lines with file in them, and replace
    subprocess.call("/home/lukasz/bashdate.sh")
    with
    subprocess.call(['/home/lukasz/bashdate.sh', year, month, month_name])

    and in the bash script, replace the cat ... rm lines with (eg)
    y=$1; m=$2; mn=$3
    which puts the year, month, and month-name into shell variables y, m, and mn.

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

Sidebar

Related Questions

<script type=text/javascript src=/scripts/a.js></script> <script type=text/javascript src=/scripts/b.js></script> I have two simple JS scripts, loaded in
I have two ruby script cron jobs that I'm trying to run under Ubuntu
Here is the two scripts I have Script 1: <? include('config.php'); $json = $_POST['payload'];
I have two simple scripts, the first shows a div when clicked. Inside that
I have simple script which contains two pages - script.php and function.php. Script.php contains
I have two simple shell scripts to run my solr installation in a screen
I have some simple scripts that allow me to change where certain versions of
I have two python scripts, lets call them file1.py and file2.py , where I
I am doing some simple math recessively in a python script and am getting
I have two simple submit buttons on my form, which work just fine: <button

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.