Re: spawn sh -c "ssh -T $host -l $user <$JOBSCRIPT" #HowCanI elim sh?



In article <gcs4m5-0qv.ln1@xxxxxxxxx>, Cameron Laird <claird@xxxxxxxxx> wrote:
In article <1217378101.478578@xxxxxxxxxxxx>,
Name withheld by request <anonb6e9@xxxxxxxxxxxx> wrote:
pls consider this snip of expect:

spawn /bin/bash -c "ssh -T $host -l $user <$JOBSCRIPT"
# had to use the 'sh -c' approach support the '<' redirection

# ====================================================================
# wait for passwd prompt
# normal next send enters password
# ====================================================================
set __comment_on_last_send "no send yet, just spawned ssh"
expect {

"assword:" {
send "$PW\r"
set _comment_on_last_send "passwd entered, waiting on job completion..."
}
--snip

Is there a way to eliminate the bash shell in the spawn above?
Notice that the remote script is supplied as the STDIN to ssh.

Sure, there are ways ... They're probably going to be more
tedious to implement than the minor burden of the /bin/bash.

OK then I can stick to bash, or a smaller shell.
(cygwin comes w/a small shell called 'ash'.)

Is it enough to have Expect read each line of $JOBSCRIPT and
pass it to the spawned ssh?

I'm not smart enough to know, I could test your soln though.

What kind of control do you have over $JOBSCRIPT?

not much, I'm using the expect script as a wrapper/launcher for cygwin
cron jobs (so just about any script needs to be sypported). The user's
credentials in a cygwin cron job are not sufficent to write to remote
(network) drives, hence the password-authenticated ssh session.

--
thanks very much for your help
.



Relevant Pages

  • Checking for existence of command prior to execution
    ... alone in an interactive shell it works though. ... it will fail if I add ssh to the list of commands which is ... aliased by the tcsh that is calling the above script. ...
    (comp.os.linux.misc)
  • Command confusion (ssh from php)
    ... Therefore I will put all of this in a perl ... this script will make 2 folders. ... If I run "perl myscript.pl" from the cygwin command line, ... ssh password), ...
    (alt.php)
  • modify ksh environment when called from ssh
    ... I'm having trouble setting up my environment for a script to be called ... from ssh. ... I have a script that contains: ssh -l user A myprog ... It appears that type of invocation of ksh (not an interactive shell) ...
    (comp.unix.shell)
  • SSH not closing after script exit
    ... remote server, over which we connect to the machine to administer. ... created a script which takes care of the SSH connection; ... Our assumption is that the fork to the new shell starts the script, ...
    (comp.os.linux.security)
  • .ssh directory permission denied
    ... When I spawn $HOME/.ssh, an error message shows: ... I am using Cygwin to run the expect script, ... I have tried using chmod 755 .ssh to change the permission, ...
    (comp.unix.shell)