Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple Run() commands #58

Open
mpenning opened this issue Oct 8, 2023 · 0 comments
Open

Support for multiple Run() commands #58

mpenning opened this issue Oct 8, 2023 · 0 comments

Comments

@mpenning
Copy link

mpenning commented Oct 8, 2023

In a similar vein to #13, is it possible to Run() multiple commands in a single session?

This fails with a panic on my system... a single command works just fine of course... single-command working copy, ref: route_views_go git hash 5e4bb51.

Doing this may require something similar to go-expect. Will goph support this functionality natively, or do I need a third-party library?

package main

import (
        "fmt"

        "github.com/gleich/logoru"
        "github.com/melbahja/goph"
)

func main() {

        // route-views username 'rviews' with no password
        client01, err := goph.New("rviews", "route-views.routeviews.org", goph.Password(""))
        if err != nil {
                logoru.Critical(err.Error())
        }
        defer client01.Close()

        // get the best BGP route info for 4.2.2.2
        cmdout01, err := client01.Run(fmt.Sprintf("show ip bgp %s bestpath", "4.2.2.2"))
        if err != nil {
                logoru.Critical(err.Error())
        }

        // get the best BGP route info for 8.8.8.8
        cmdout02, err := client01.Run(fmt.Sprintf("show ip bgp %s bestpath", "8.8.8.8"))
        if err != nil {
                logoru.Critical(err.Error())
        }

        logoru.Info(string(cmdout01))
        logoru.Info(string(cmdout02))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant