For Programmers: Free Programming Magazines  


Home > Archive > Tcl > July 2005 > spawn and redirect stderr









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author spawn and redirect stderr
powah

2005-07-24, 8:59 pm

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

2005-07-24, 8:59 pm



powah wrote:

> 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
>
>
>
> will result this error:
>
>
> /dev/null: Unknown Object Identifier (Sub-id not found: mib-2 ->
> /dev/null)
>


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

2005-07-24, 8:59 pm

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-news@hartweg.us> wrote in message
news:64VDe.6$j56.1@dfw-service2.ext.ray.com...


powah wrote:

> 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
>
>
>
> will result this error:
>
>
> /dev/null: Unknown Object Identifier (Sub-id not found: mib-2 ->
> /dev/null)
>


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


Cameron Laird

2005-07-24, 8:59 pm

In article <m5qdna8CSfrcbn3fRVn-vA@adelphia.com>,
Patrick Dunnigan <pdunnigan@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/

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com