Opening ROXTerm from within another Program

2013-03-05
2013-03-06
  • Daniel Lintott

    Daniel Lintott - 2013-03-05

    I am working on using ROXTerm as a terminal for GNS3 (http://www.gns3.net). I have created a wrapper script to open ROXTerm and auto-press the Return key.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    #!/bin/bash
    
    #$1 = Device Name %d (R1)
    #$2 = Device Server %h (127.0.0.1)
    #$3 = Device Port %p (2101)
    
    roxterm --tab -n $1 -e telnet $2 $3 >/dev/null 2>&1 &
    xdotool sleep 0.4     #Wait for terminal to open and telnet to connect
    xdotool key Return    #Send Return key to terminal
    

    When this script is executed from a terminal (gnome-terminal), it executes fine and ROXTerm opens fine. When I try and run the script from within the GNS3 Application, I am presented with the following error.

    Error connecting to dbus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

    The same error also appears if I call ROXTerm direct from within GNS3 (bypassing the wrapper script).

    Any ideas on what would be causing this.
    Many Thanks

     
    Last edit: Daniel Lintott 2013-03-05
  • Tony Houghton

    Tony Houghton - 2013-03-05

    It looks as if GNS3 is running in an environment separate from the X session, so roxterm can't find the D-Bus session bus via the DBUS_SESSION_BUS_ADDRESS variable. You should be able to look up the variable in a file in ~/.dbus/session-bus/ eg
    add:

    eval `grep ^DBUS_SESSION_BUS_ADDRESS= ~/.dbus/session-bus/*`
    export DBUS_SESSION_BUS_ADDRESS
    

    before your line 7.

    This won't be reliable if you are logged into more than one desktop session at a time.

    I would also suggest using roxterm's --fork option, otherwise if roxterm wasn't already running your script will stop on that line until roxterm exits. Also --fork should be safer than relying on the sleep alone, but maybe still not 100% reliable.

     
    Last edit: Tony Houghton 2013-03-05
  • Daniel Lintott

    Daniel Lintott - 2013-03-05

    I have just tried adding the code you suggested but unfortunately it doesn't seem to have any effect. GNS3 is coded in Python using Qt4, if that's of any use.

    GNS3 is also run using gksudo or sudo to give elevated privilages, see below.

    gksudo -k gns3 -D /home/daniel/Desktop/GNS3.desktop
    

    The reason I used the sleep instead of the --fork option was to prevent the extra un-needed tab that is generated... unless I have missed something.

     
    Last edit: Daniel Lintott 2013-03-05
  • Tony Houghton

    Tony Houghton - 2013-03-05

    Assuming the desktop is running as normal user daniel, you would have to use ~daniel/ instead of ~. And you should probably get GNS to run your script as user daniel too, if possible, or at least use sudo -u daniel in front of the roxterm command.

    I don't understand why you would get an extra unneeded tab by using --fork. If there isn't already a roxterm window open your script won't work without --fork.

     
  • Daniel Lintott

    Daniel Lintott - 2013-03-05

    Thanks again for your help. I have now managed to get the script working as intended. I have had to leave the sleep in place as it needs a delay for telnet to connect.

     
  • Tony Houghton

    Tony Houghton - 2013-03-06

    I wasn't sure you'd need to keep the sleep or not. At least with --fork it only has to wait for telnet and not also for roxterm to start, but I hoped it might also ensure that the return key press gets into a buffer where telnet would pick it up when ready.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks