# Issue non-interactive Gogo shell command

From the OSGi console, I can issue the dropAllPacketsRpc on command with no trouble. I need to issue that same command in a non-interactive mode, for a CBench performance test I'm writing.

If I put a gosh_profile file in controller/opendaylight/distribution/opendaylight/src/main/resources/etc, I can do things like change the OSGi prompt successfully. However, simply putting dropAllPacketsRpc on in that gosh_profile (like I would do with other shells) throws an error after build/run (command not found).

My two running theories are that there's another syntax for issuing non-builtin commands, or that the command I'm running hasn't been setup at the time gosh_profile is sourced, so it really doesn't exist.

Obviously I don't know much about Gogo scripts, OSGi and such. I've Googled pretty hard, but I'm having a very tough time finding relevant resources. Links are appreciated, even if you don't have a direct answer.

Update: I'm able to add any valid OSGi console statement (like dropAllPacketsRpc on) to a script, then successfully run source /path/to/script.sh at the console. However, when I add the source command to gosh_profile, keeping the script syntax the same, I get the same consoleCommandNotFoundException: Command not found: dropAllPacketsRpc. That seems to eliminate my syntax theory and support the theory that the commands built by plugins aren't available at the time gosh_profile is sourced. That seems...hard to get around. *frustration*

edit retag close merge delete

Do you mean you want to trigger an OSGi command? What do you man by non-builtin commands?

( 2014-05-27 09:24:10 -0800 )edit

I think I mean commands that are not added by plugins, but are shipped with the shell. For example, dropAllPacketsRpc is defined in openflowplugin/<snip>/DropTestCommandProvider.java while commands like setting the prompt ship with the Gogo shell (and work in gosh_profile).

( 2014-05-27 10:56:37 -0800 )edit
1

Can you work with telnet-ing or ssh-ing into OSGi console? This has more info: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fconsole_shell.htm

( 2014-05-28 07:14:05 -0800 )edit

Yeah, I was just working on the telnet route (via IRC late yesterday). Seems to be a workable solution, if a bit ugly. Thanks (I would +1, but <5 karma noob)!

( 2014-05-28 11:59:31 -0800 )edit

Sort by » oldest newest most voted

I was able to accomplish the goal, non-interactively sending plugin-built statements (like dropAllPacketsRpc on) to the OSGi console, via a different mechanism.

Giving the -start or -start [port_num] flag to run.sh makes OSGi listen for connections to the shell via telnet (defaults to port 2400), instead of dropping the user into a shell. You can then echo arbitrary commands to a telnet session:

issue_odl_config()
{
# Give dropAllPackets command via telnet to OSGi
# This is a bit of a hack, but it's the only method I know of
if ! command -v telnet &>/dev/null; then
sudo yum install -y telnet
fi
echo "dropAllPacketsRpc on" | telnet 127.0.0.1 \$OSGI_PORT
}

more