From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,36f89f38be16f64 X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2003-12-22 13:54:56 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.stanford.edu!news-proxy.abbnm.com!newsboy.eng.abbnm.com!not-for-mail From: peter@abbnm.com (Peter da Silva) Newsgroups: comp.unix.tru64 Subject: Re: /dev/stdin .... ? Date: Mon, 22 Dec 2003 21:30:21 +0000 (UTC) Organization: ABB Network Management Division Message-ID: References: NNTP-Posting-Host: grendel.eng.abbnm.com X-Trace: jeeves.eng.abbnm.com 1072128621 43799 198.178.0.150 (22 Dec 2003 21:30:21 GMT) X-Complaints-To: usenet@jeeves.eng.abbnm.com NNTP-Posting-Date: Mon, 22 Dec 2003 21:30:21 +0000 (UTC) X-Newsreader: trn 4.0-test76 (Apr 2, 2001) Originator: peter@abbnm.com (Peter da Silva) Xref: archiver1.google.com comp.unix.tru64:11052 In article , Barth Weishoff 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 < 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 < > 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`