Networker

Re: [Networker] command line recover options?

2008-06-26 14:23:13
Subject: Re: [Networker] command line recover options?
From: Valdis Kletnieks <Valdis.Kletnieks AT VT DOT EDU>
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Date: Thu, 26 Jun 2008 14:18:25 -0400
On Wed, 25 Jun 2008 15:47:21 EDT, "Goslin, Paul" said:
> The original poster stated that he needed to do this via command line as
> he has to automate this.. So Interactive is not an option...  

How about something like:

(echo "add *"; echo "delete foo1"; echo "delete foo2"; echo "recover") | recover

That's worked with most "interactive" programs that read from /dev/stdin.  I've
been known to hack up a similar thing using the 'script' command if the
program insists on reading /dev/tty instead...

Ah... Found it.  I had to screen-scrape a program (so not only did the
input become fun, but afterwards there was some seriously ugly 'sed' work
to eliminate control characters (program name changed to XXY to protect
the guilty) - here's what I ended up doing on a Solaris 9 box:

# Now for some uglyness.  If this were Lisp, we could pass
# an arbitrary lambda-expression as SHELL,  Unfortunately,
# it's ksh.  We do all of this because XXY refuses to
# give us a flat ascii file, so we need to engage in some
# screen-scraping.
cat >> /tmp/inuse.helper.$$ << EOF
#!/bin/sh
TERM=vt100
export TERM
stty rows 50
echo q | /usr/bin/XXY
EOF
chmod +x /tmp/inuse.helper.$$
SHELL=/tmp/inuse.helper.$$ script /tmp/inuse.$$ > /dev/null 2>&1

(On Linux, a simple "echo q | script -c /usr/bin/XXY /tmp/inuse.$$" would
probably have sufficed)....

To sign off this list, send email to listserv AT listserv.temple DOT edu and 
type "signoff networker" in the body of the email. Please write to 
networker-request AT listserv.temple DOT edu if you have any problems with this 
list. You can access the archives at 
http://listserv.temple.edu/archives/networker.html or
via RSS at http://listserv.temple.edu/cgi-bin/wa?RSS&L=NETWORKER