Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • This is great information and I think I could use it. The one thing I think I should mention though is that 'VAR' is a variable (integer) defined by the python script (that is to call the shell script) so we may not need to echo it, right? since python already knows its value. Commented Sep 3, 2015 at 20:00
  • @kadamwolfe Yeah..you can use it directly then as I have used in the second object generation..I was just pointing out the processes in my sample script..fit it to meet your need :) Commented Sep 3, 2015 at 20:04
  • nice. so something like.... subprocess.Popen(['bash', '/path/to/script', '--args'], stdin="some text" VAR) ? Commented Sep 3, 2015 at 20:06
  • @kadamwolfe I probably have misunderstood your point, you can't directly use a string as STDIN as it does not have fileno attribute..you can combine the two into a simple one liner: subprocess.Popen(['bash', '/path/to/script'], stdin=subprocess.Popen(['/bin/echo', var], stdout=subprocess.PIPE).stdout) ,if its a one time run then you can consider subprocess.call instead of subprocess.Popen.. Commented Sep 3, 2015 at 20:21
  • While I do appreciate the help, I'm not sure it resolves my issue. I'm checking if a variable's value is greater than another and if so, echo that variable's value to a shell script (preferably pre-pended by a text string. if VAR > NUMBER: <echo text string + VAR's value to /path/to/script --args> Commented Sep 3, 2015 at 20:40