]>
Commit | Line | Data |
---|---|---|
f73dda09 JA |
1 | Date: Fri, 21 Sep 2001 14:50:29 -0400 |
2 | From: "Jason M. Felice" <jfelice@cronosys.com> | |
3 | To: bash-maintainers@gnu.org, chet@po.cwru.edu | |
4 | Subject: Bash co-processes functions | |
5 | Message-ID: <20010921145029.A6093@argo.eraserhead.net> | |
6 | Mime-Version: 1.0 | |
7 | ||
8 | Attached to this message you will find coprocess.bash and coshell.bash. | |
9 | Here's a brief synopsis of use: | |
10 | ||
11 | coprocess open telnet localhost | |
12 | while coprocess read il ; do | |
13 | echo "$il" | |
14 | case "$il" in | |
15 | *ogin:*) | |
16 | coprocess print 'user' | |
17 | ;; | |
18 | *ord:*) | |
19 | echo 'pass' |coprocess print --stdin | |
20 | ;; | |
21 | *$ *) | |
22 | coprocess print 'exit' | |
23 | break | |
24 | ;; | |
25 | esac | |
26 | done | |
27 | coprocess close | |
28 | ||
29 | And here's an example of the coshell function: | |
30 | ||
31 | coshell open ssh -l root otherbox | |
32 | coshell eval hostname | |
33 | coshell ls -l | |
34 | if coshell test -d /tmp ; then echo 'otherbox has a /tmp!' ; fi | |
35 | ||
36 | coshell sendfile /var/lib/upgrade.rpm /tmp/test.rpm || exit $? | |
37 | coshell eval rpm -ivh /tmp/test.rpm || exit $? | |
38 | coshell eval rm -f /tmp/test.rpm || exit $? | |
39 | coshell close | |
40 | exit 0 | |
41 | ||
42 | There are a few minor issues that I'd like to work out, but it works well | |
43 | enough for me ;-) The issues are: | |
44 | ||
45 | - Shell quoting issue with 'coshell eval' commands - need to somehow | |
46 | re-quote words. | |
47 | - Interactive commands hang 'coshell eval', tried redirecting in </dev/null | |
48 | to executed command, but it caused strange shell exit problems. | |
49 | - Some way to copy stdin from local coshell eval to remote shell. Probably | |
50 | logically impossible, but would be wonderfully useful. | |
51 | ||
52 | I'm using it for writing scripts to publish websites and other scripts to | |
53 | co-located servers. |