Ray Salemi
Ray Salemi

Reputation: 5933

Providing data to Python input() from Bash

Given this program named foo.py

#! /usr/bin/env python
foo = input('input foo: ')
print(foo)

How do I run this from foo_test.sh?

Upvotes: 0

Views: 46

Answers (1)

Ray Salemi
Ray Salemi

Reputation: 5933

I figured it out so thought I'd post it. Simple, of course:

 % echo 'foodata' | ./foo.py

That does the job.

Upvotes: 2

Related Questions