Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
From: peter@abbnm.com (Peter da Silva)
Subject: Re: /dev/stdin ....  ?
Date: Mon, 22 Dec 2003 21:30:21 +0000 (UTC)	[thread overview]
Message-ID: <bs7npd$1aon$1@jeeves.eng.abbnm.com> (raw)
In-Reply-To: efbd1d5e.0312221147.57aecc0@posting.google.com

In article <efbd1d5e.0312221147.57aecc0@posting.google.com>,
Barth Weishoff <barth.e.weishoff@cummins.com> wrote:
> Hello group,
> 
>   I've run this by HP, and they can't seem to come up with a clear
> answer.   Anyway, long story short, I've been using here documents
> with OpenSSH's SFTP program to transfer files among hosts.  Example
> (stolen from http://www.snailbook.com/faq/scripting-sftp.auto.html )
> 
>    #!/bin/sh
>   echo "OK, starting now..."
>   sftp -b /dev/stdin remotehost <<EOF
>   cd pub
>   ...

  -b batchfile
       Batch mode reads a series of commands from an input batchfile instead
       of stdin.

Looks like leaving the "-b /dev/stdin" out completely would work. The
problem is that sftp may not be written intelligently and to only act
as if it's interactive if input is from a terminal. Given that this
option even exists, when you should be able to just run

	sftp [user@]host < batchfile

I suspect that's the case, but you can try.

> exist, and I'm not sure what to substitute on a Tru64 box in order to
> make this work.   I have tried:
> 
>  sftp -b `tty` somehost <<HEREDOC
> 
> but to no avail.  

No, that wouldn't work. `tty` (or /dev/tty, which should act the same as
the /dev/... string that comes out of `tty`) is always the terminal, and
never anything you can redirect... that's what it's for, after all.

You can create an equivalent to "/dev/stdin" using a named pipe, but
really the best way around this is something like:

	BATCHFILE=/some/secure/directory/batch$$.sftp
	trap 'rm $BATCHFILE' 0		# to guarantee it's cleaned up

	cat > $BATCHFILE << EOF
	commands
	EOF
	sftp -b $BATCHFILE user@host

> lrwx------    1 cj037    cj037          64 Dec 22 13:44 0 ->
> /dev/pts/2

/proc/self/0 is not going to always be linked to the tty. In fact, if that's
linked to the tty in *any* case where stdin is redirected I would be utterly
shocked. Try "ls -l /proc/self/0 < /some/file" and see what happens.

> Does anyone have any idea how to accomplish this under Tru64?  Thanks!

See above. You have a non-portable example. The way to make it portable is
to fix sftp to do what most portable programs do... use the file named "-"
as a special case for stdin... or to use an explicit batch file.

-- 
I've seen things you people can't imagine. Chimneysweeps on fire over the roofs
of London. I've watched kite-strings glitter in the sun at Hyde Park Gate.  All
these things will be lost in time, like chalk-paintings in the rain.   `-_-'
Time for your nap.  | Peter da Silva | Har du kramat din varg, idag?    'U`


  reply	other threads:[~2003-12-22 21:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-22 19:47 /dev/stdin .... ? Barth Weishoff
2003-12-22 21:30 ` Peter da Silva [this message]
2003-12-23  4:23   ` Finnbarr P. Murphy
2003-12-22 21:32 ` Spider Boardman
2003-12-23  2:47   ` Barth Weishoff
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox