Sponsored Content
Full Discussion: KSH, coprocess and SSH
Top Forums Shell Programming and Scripting KSH, coprocess and SSH Post 302319418 by colemar on Monday 25th of May 2009 07:24:32 AM
Old 05-25-2009
A coroutine (two-way pipe) seems to be overkill, since you are not waiting for the remote user/password prompt.
To do such a simple thing a here-document is enough:
Code:
ssh ... << EOT
password
EOT

The problem could be that you send the password too early.
If you are willing to wait for a password prompt then you need a two-way pipe and have to read -p before print -p.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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 # ... (4 Replies)
Discussion started by: Mugin
4 Replies

2. 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

3. Shell Programming and Scripting

ssh into a shell script (KSH)

Hi all, Just like to ask if it is possible to do the following: 1. Have a shell script that calls ssh username@destinationhost 2. Upon successful verification, we ssh into the destination host and automatically use ksh to run a shell script that resides in the destination host. (Hopefully no... (8 Replies)
Discussion started by: rockysfr
8 Replies

4. 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

5. Shell Programming and Scripting

ssh commands in ksh question

Is there a way to shorten these commands? because this script asks for a password 3 times scp -p /usr/local/bin/${script_name} ${servername$iy]}://usr/local/bin/ ssh ${servernames} /usr/local/bin/${script_name} ssh ${servernames} rm -f /usr/local/bin/${script_name} Basically, I'm creating a... (3 Replies)
Discussion started by: pdtak
3 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

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

8. Shell Programming and Scripting

Help with ssh ksh script

Hi, I am trying to figure out a ksh script that i have and i think i found it but not sure. i am having to scp or sftp files from my remote server over 2 others to the destination. i have the rsa keys setup for the servers on my end and the username and password for the final server. ... (3 Replies)
Discussion started by: ksh_beginner
3 Replies

9. Shell Programming and Scripting

Ssh from a ksh returning not found message

Script name is test.ksh I know that that the ssh command is working properly, this can be verified by the value returned in respond variable. It is unique to the remote server _____________________________________________________ respond=$(ssh $remoteHost find... (3 Replies)
Discussion started by: Adagio
3 Replies

10. Shell Programming and Scripting

ksh - keep argument variables after ssh

i have a script that should ssh to different host/server. See below: ./script.ksh var1 var2 var3 case $ser in ser1) depo='appr1' set -A aprrA aprrB ssh ser2 "/home/dir/script.ksh $1 $2 $3" ssh ser3 "/home/dir/script.ksh $1 $2 $3" ssh ser4... (4 Replies)
Discussion started by: erin00
4 Replies
PCL(3)							    Portable Coroutine Library							    PCL(3)

NAME
co_create, co_call, co_resume, co_delete, co_exit_to, co_exit, co_current - C coroutine management SYNOPSIS
#include <pcl.h> coroutine_t co_create(void *func, void *data, void *stack, int stacksize); void co_delete(coroutine_t co); void co_call(coroutine_t co); void co_resume(void); void co_exit_to(coroutine_t co); void co_exit(void); coroutine_t co_current(void); DESCRIPTION
The Portable Coroutine Library (PCL) implements the low level functionality for coroutines. For a definition of the term coroutine see The Art of Computer Programming by Donald E. Knuth. Coroutines are a very simple cooperative multitasking environment where the switch from one task to another is done explicitly by a function call. Coroutines are a lot faster than processes or threads switch, since there is no OS kernel involvement for the operation. This document defines an API for the low level handling of coroutines i.e. creating and deleting coroutines and switching between them. Higher level functionality (scheduler, etc.) is not covered. Functions The following functions are defined: coroutine_t co_create(void *func, void *data, void *stack, int stacksize); This function creates a new coroutine. func is the entry point of the coroutine. It will be called with one arg, a void *, which holds the data passed through the data parameter. If func terminates, the associated coroutine is deleted. stack is the base of the stack this coroutine will use and stacksize its size in bytes. You may pass a NULL pointer for stack in which case the memory will be allocated by co_create itself. Both, stack and stacksize are aligned to system requirements. A stacksize of less then 4096 bytes will be rejected. You have to make sure, that the stack is large enough for your coroutine and possible signal handlers (see below). The stack will not grow! (Exception: the main coroutine uses the standard system stack which may still grow) On success, a handle (coroutine_t) for a new coroutine is returned, otherwise NULL. void co_delete(coroutine_t co); This function deletes the given coroutine co. If the stack for this coroutine was allocated by co_create it will be freed. After a coroutine handle was passed to co_delete it is invalid and may not be used any more. It is invalid for a coroutine to delete itself with this function. void co_call(coroutine_t co); This function passes execution to the given coroutine co. The first time the coroutine is executed, its entry point func is called, and the data parameter used during the call to co_create is passed to func. The current coroutine is suspended until another one restarts it with a co_call or co_resume call. Calling oneself returns immediately. void co_resume(void); This function passes execution back to the coroutine which either initially started this one or restarted it after a prior co_resume. void co_exit_to(coroutine_t co); This function does the same a co_delete(co_current()) followed by a co_call would do. That is, it deletes itself and then passes execution to another coroutine co. void co_exit(void); This function does the same a co_delete(co_current()) followed by a co_resume would do. That is, it deletes itself and then passes execution back to the coroutine which either initially started this one or restarted it after a prior co_resume. coroutine_t co_current(void); This function returns the currently running coroutine. Notes Some interactions with other parts of the system are covered here. Signals First, a signal handler is not defined to run in any specific coroutine. The only way to leave the signal handler is by a return statement. Second, the signal handler may run with the stack of any coroutine, even with the stack of library internal coroutines which have an undefined stack size (just enough to perform a kernel call). Using and alternate stack for signal processing (see sigaltstack(2)) is recommended! Conclusion: avoid signals like a plague. The only thing you may do reliable is setting some global variables and return. Simple kernel calls may work too, but nowadays it's pretty hairy to tell, which function really is a kernel call. (Btw, all this applies to normal C programs, too. The coroutines just add one more problem) setjmp/longjmp The use of setjmp(2)/longjmp(2) is limited to jumping inside one coroutine. Never try to jump from one coroutine to another with longjmp(2). DIAGNOSTICS
Some fatal errors are caught by the library. If one occurs, a short message is written to file descriptor 2 (stderr) and a segmentation violation is generated. [PCL]: Cannot delete itself A coroutine has called co_delete with it's own handle. [PCL]: Resume to deleted coroutine A coroutine has deleted itself with co_exit or co_exit_to and the coroutine that was activated by the exit tried a co_resume. [PCL]: Stale coroutine called Someone tried to active a coroutine that has already been deleted. This error is only detected, if the stack of the deleted corou- tine is still resident in memory. [PCL]: Context switch failed Low level error generated by the library in case a context switch between two coroutines failes. SEE ALSO
Original coroutine library at http://www.goron.de/~froese/coro/coro.html . GNU Pth library at http://www.gnu.org/software/pth/ . AUTHOR
Developed by Davide Libenzi < davidel@xmailserver.org >. Ideas and man page base source taken by the coroutine library developed by E. Toernig < froese@gmx.de >. Also some code and ideas comes from the GNU Pth library available at http://www.gnu.org/software/pth/ . BUGS
There are no known bugs. But, this library is still in development even if it results very stable and pretty much ready for production use. Bug reports and comments to Davide Libenzi < davidel@xmailserver.org >. GNU
1.6 PCL(3)
All times are GMT -4. The time now is 05:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy