Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

spawn and redirect stderr

488 views
Skip to first unread message

powah

unread,
Jul 21, 2005, 5:18:58 PM7/21/05
to
I want to spawn a process and redirect stderr to /dev/null.

e.g.
This work in the shell:
snmpgetnext -v2c -c public localhost:9151 loggingLevel >& /dev/null

Doing this in an expect script:
spawn -noecho snmpgetnext -v2c -c public localhost:9151 loggingLevel
>& /dev/null

will result this error:
>&: Unknown Object Identifier (Sub-id not found: mib-2 -> >&)
/dev/null: Unknown Object Identifier (Sub-id not found: mib-2 ->
/dev/null)


Please help.

Bruce Hartweg

unread,
Jul 21, 2005, 6:11:14 PM7/21/05
to

powah wrote:

the spawn command does not support any redirection - expect is
made to interact with the program
spawn passes all arguments on the the program and snmpgetnext
has no idea what to do with an arg of ">&"

if you just need to run this command and not interact with it
use exec instead of spawn and it DOES support redirecting stderr
otherwise your expect commands after spawning can just ignore the
lines that would have been redirected

if for some reason you really need to interact with it, but also
can't deal with the stderr for some reason, you could always NOT
spawn snmpgetnext, but rather just spawn a shell and then use
send to run your command with the redirection.

Bruce

Patrick Dunnigan

unread,
Jul 22, 2005, 9:23:04 AM7/22/05
to
BTW, you could use Scotty for snmp gets and cut out the expect and exec
pieces.

http://wwwhome.cs.utwente.nl/~schoenw/scotty/


"Bruce Hartweg" <bruce...@hartweg.us> wrote in message
news:64VDe.6$j5...@dfw-service2.ext.ray.com...

Cameron Laird

unread,
Jul 22, 2005, 1:08:02 PM7/22/05
to
In article <m5qdna8CSfr...@adelphia.com>,

Patrick Dunnigan <pdun...@adelphia.net> wrote:
>BTW, you could use Scotty for snmp gets and cut out the expect and exec
>pieces.
>
>http://wwwhome.cs.utwente.nl/~schoenw/scotty/
.
.
.
Ain't it the truth.

I resort to rather vulgar vernacular to emphasize my, "Me,
too", point: Scotty <URL: http://wiki.tcl.tk/scotty > is
a GREAT thing for network administrators to have in their
toolkits. While Juergen has largely moved on from his cre-
ation, and it's been years since anyone has done much
maintenance on Scotty, its convenience, power, and flexi-
bility keep it years ahead of many alternative technologies
(including, for the most part, Expect-over-snmpget). Try
it; you're likely to like it.

0 new messages