I/O redirection within a coprocess


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting I/O redirection within a coprocess
# 1  
Old 10-20-2003
Question I/O redirection within a coprocess

Hello everybody,

I have a question about I/O redirection within a coprocess.
I want to setup a coprocess and then redirect output to a file on a remote machine.

Here's some Perderabo code modified

exec 4>&1


#
# Section 1 --- Prove that we can talk with the hosts in HOSTLIST
# Part 1 --- telnet to each and touch a file

for HOST in $HOSTLIST ; do
telnet $HOST >&4 2>&4 |&
sleep $DELAY
print -p cd /destiny
sleep $DELAY
print -p sed 's/bla/bli/' somefile > somefile_new
sleep $DELAY
print -p mv somefile_new somefile
sleep $DELAY
print -p exit
wait
done


The I/O redirection seems to disappear in the coprocess. Can someone point me to a solution in this matter.

Thanx Mugin
# 2  
Old 10-20-2003
Ahem...that i/o redirection works fine for me. It causes the output of the telnet session to appear on the screen just as it was supposed to do. Without the redirection, I would need to do a "read -p" for each line. That is the normal case for a coprocess. You do stuff like this:

bc |&

print -p 1 + 2
read -p result
echo $result

I don't understand what you plan on trying. Redirecting to a file on a remote system will require nfs or something.
# 3  
Old 10-20-2003
Perderabo, thanx for your fast reply.

Let me explain what i want to do.
I want to edit a file with sed on some remote machines.
Everything works fine, also the sed command output, but the ">"
part after sed does not seem to work ( i do not get any output from that part).
Should i write a little sed script before, set up a coprocess for ftp and then send the script over in order for the telnetcoprocess to execute it?Smilie

Mugin
# 4  
Old 10-20-2003
I don't understand what you are trying to do. Post your script. Maybe that will help.
# 5  
Old 10-21-2003
Are you sure telnet is the correct program to use for running processes remotely on another machine?

Shouldn't you be trying to use something like remsh?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SQL/Plus in a coprocess example. Also saves query results into shell variables

While assisting a forum member, I recommended running SQL/Plus in a coprocess (to make database connections and run a test script) for the duration of his script rather than starting/stopping it once for every row in a file he was processing. I recalled I made a coprocess example for folks at... (2 Replies)
Discussion started by: gary_w
2 Replies

2. Shell Programming and Scripting

Redirection

Hello All, I am using the below script to gather various tools running by the user, we have more than 100 tools running on the server so my challenge is to redirect memory & cpu load to the file with the name of the tool.so am using the below script i am stucking how to redirect to the file... (2 Replies)
Discussion started by: ajaincv
2 Replies

3. Shell Programming and Scripting

I/O redirection

Hello everyone,I'm reading a book and there's code fragment: exec 3>&1 ls -l 2>&1 >&3 3>&- | grep bad 3>&- exec 3>&- It says that the red part of that code does not close fd 3 but the green does close the fd 3.I can't understand that.....Why?Any predicate will be appreciated.:) (18 Replies)
Discussion started by: homeboy
18 Replies

4. UNIX for Dummies Questions & Answers

Help with Redirection

Hi Guys, I m new to UNIX and new to this forum. Was wondering if someone can help me understand redirection (standard input output pipeline etc) for starters, not too sure what this would mean who | sort > sortedfile | pr | lp im starting to understand common commands but when throwing... (2 Replies)
Discussion started by: jmack123
2 Replies

5. Shell Programming and Scripting

KSH, coprocess and SSH

Hi there, I want to connect to a Cisco router with a KSH script via coprocess: telnet 192.168.2.82|& print -p “login” print -p "password" With telnet it works. Now I want to use SSH: ssh -T -l login 192.168.2.82|& print -p "password" The router answer me I enter a bad... (7 Replies)
Discussion started by: sylvainkalache
7 Replies

6. Shell Programming and Scripting

Get coprocess output into var

This is probably a simple one for the wise. I have just started using a coprocess (first time) in order to facilitate telnet'ing from inside a shell script. It's working, but when I run a remote command I need to get the output into a local variable, but alas my kung-fu is weak. #!... (10 Replies)
Discussion started by: dan-e
10 Replies

7. Shell Programming and Scripting

redirection

Hi, The code below works, it's a part of a bash shell script that serve to search a pattern $pattern_da_cercare in the files contained in a directory $directory_iniziale. Now the proble is: How can I redirect stderr to a file? PS: so I want to redirect ALL the errors to a file. I tryed... (9 Replies)
Discussion started by: DNAx86
9 Replies

8. Shell Programming and Scripting

awk - coprocess???

Hi can any one let me know if awk doesnt work with the coprocess??? I have tried a simple example mentioned below but couldnt get it working seems like awk doesnt work with the coprocess concept. I would appreciate very much for any inputs on this. exec 4>&1 awk -v count=$COUNT >&4 2>&4 |&... (6 Replies)
Discussion started by: ahmedwaseem2000
6 Replies

9. Shell Programming and Scripting

Korn Shell Coprocess Performance Question

I am wracking my brains over this. I am trying to use a Korn Shell script to execute an Oracle PL/SQL procedure, using the Oracle command line interface (sqlplus). The script starts sqlplus in a coprocess, and the two processes communicate using a two-way pipe. The bgnice option is off, so both... (8 Replies)
Discussion started by: Mark Puddephat
8 Replies

10. Programming

Help with redirection

Here is my problem. I don't know make this redirection thing work. The output file (called output.c) looks like this #include<stdio.h> int main() { int k; int m; print f("%d\n", k); printf("%d\n", m); return 0; } the input file(called input.c) is this #include<stdio.h> int... (2 Replies)
Discussion started by: Shallon1
2 Replies
Login or Register to Ask a Question