vtysh input requires TTY, but I want to drive it from a pipe

151 views
Skip to first unread message

Chris Ward

unread,
Oct 25, 2021, 12:13:31 PM10/25/21
to sonicproject
I want to drive vtysh ( the shell which interprets bgp commands ) from another process, with its stdin and stdout connected via pipes. When I try this on 'master', I get an error message to the effect that stdin is not a TTY, and my bgp commands are not run.

What would it take to fix this ? I am willing to do some amount of coding.

Chris Ward

unread,
Oct 26, 2021, 5:24:24 AM10/26/21
to sonicproject
I have coded an initial implementation of this and made a PR https://github.com/Azure/sonic-frr/pull/21 . I'm currently awaiting my manager to give me permission to sign the CLA; also it will take a while for me to attempt to build this as I think I need to build the whole of SONiC. 
Feedback as to the acceptability of the patch would be appreciated.

Masaru OKI

unread,
Oct 26, 2021, 5:34:54 AM10/26/21
to Chris Ward, sonicproject
I use vtysh -c command -c command ... or vtysh -f file instead.

2021年10月26日(火) 18:24 Chris Ward <tjc...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "sonicproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonicproject...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonicproject/d298f977-b399-4f84-884f-ecbe30fa57c7n%40googlegroups.com.

Chris Ward

unread,
Oct 26, 2021, 5:41:22 AM10/26/21
to sonicproject
I can't use the '-c' form because I am trying to run vtysh as a coroutine (handling commands received from a web server). Does 'vtysh -f -' read commands from stdin ? My look at the source code suggested that '-f' was for reading a configuration file rather than for reading commands.

Chris Ward

unread,
Oct 26, 2021, 6:47:52 AM10/26/21
to sonicproject
It looks as if vtysh doesn't currently handle 'vtysh -f -' to mean read stdin as a stream, but the code looks as if it could be fairly easily adapted to do that. Would that be a better patch than the one I proposed in the PR ?

Chris Ward

unread,
Oct 26, 2021, 7:11:07 AM10/26/21
to sonicproject
I have a new proposed PR, https://github.com/Azure/sonic-frr/pull/22 , which works by interpreting 'vtysh -f -' as a request to read stdin (which can be a pipe or a file redirection). Comments appreciated !
Reply all
Reply to author
Forward
0 new messages