how to open a true terminal window using paramiko? - paramiko

Is it possible to open a terminal using paramiko like if we were executing gnome-terminal or xterm ? By terminal, I mean an actual terminal window and not a pseudo-terminal as it is done using invoke_shell method. I tried the recipe given here but it does not work.

Related

R pop-up boxes not working when run in terminal

I am using the svDialogs (an R wrapper library for zenity) to create GUI pop-up boxes, and this works fine when I run the code through either R studio, or from an R terminal session (running Ubuntu 16.04).
A minimal example is:
library(svDialogs)
dlgMessage("Hello Stackoverflow!")
However, when I run the code directly through the terminal it does not work:
Rscript --vanilla -e 'source("path/to/file.R")'
The terminal shows that the library loaded, and does not display an error message: but the pop-up does not appear! If I add an additional line after the call to dlgMessage, that line runs. i.e. if I run the modified code
library(svDialogs)
dlgMessage("Hello Stackoverflow!")
print("Goodbye Stackoverflow!")
then the second line does show in the terminal window (i.e. the code is not crashing at dlgMessage).
Happy for solutions not relying on dlgMessage if there is a workarond: I'd previously tried using Zenity natively through R using system() but couldn't get this to work.
R can be run in either interactive or non-interactive modes, with the default depending on whether or not it is assumed that there is a human operator, see documentation for interactive.
When run in non-interactive mode, R will not display any pop-up boxes. The default is that when running code in the terminal, R runs in non-interactive mode. Following the documentation above, this can be overwritten by using the command in linux
R --vanilla --interactive < "path/to/file.R"
Similarly in Windows using --ess with Rterm.exe

Send line to console in Notepad++

Is there a way to execute commands line-by-line written in NPP editor in a console.
I have already looked at the following plugins, but they seem to execute a line or chunk of code as a standalone script (i.e. not interactive):
NPPExec;
NPPConsole;
This question is similar to this one:
Run selected line in notepad++ console
but in their case the code is being saved, executed, and stopped. But I would like an interactive console, i.e. it would bring up an instance of shell (or any other console), and I can send line-by-line code from NPP editor.
It sounds like you are looking for behaviour similar to IPython and the Jupyter Notebook or maybe just a regular debugger. I don't know of any plugin that can do that in Notepad++.
If interactive behaviour after initial execution will do (e.g. for inspection of variables), you can achieve that using the interactive flag -i in NppExec like this:
cd $(CURRENT_DIRECTORY)
python -u -i $(FILE_NAME)

Run r script in background on Ubuntu server

I am working on an ubuntu server. I have an R Script which will run for several days. How would I run it in the background - that when I log out it still runs?!
When I try R script.R it says ARGUMENT 'script.R' __ignored__
First off, to run an R script in batch mode, you have several possibilities; I use the following, which works well:
Rscript scriptname.r
This, however, will run the script in the foreground. This isn’t a problem in tmux per se — just run it in a background tab. However, you can of course run it in the background in the usual way — append &:
Rscript scriptname.r &
Again, this needs to be run inside tmux (or similar) to stay alive once you log out.

Write command to gnome terminal with QProcess

I am trying to write an application with Qt in Netbeans. I am able to open the gnome terminal (in Ubuntu), however I can't seem to get a command to be executed in the terminal once it is open, e.g. to execute the 'ls' command.
Can anyone perhaps help me with some code to execute the ls command in the gnome terminal once it is opened? I am opening the terminal with the following code:
QProcess *proc = new QProcess(this);
proc->start("gnome-terminal");
if (!proc->waitForStarted()) {
}
Use -e argument:
proc->start("gnome-terminal -e 'ls'");
To keep the window open, go to Edit > Profile Preferences > Command > When command exits and change to Hold the terminal open.

Can't plot in R from tmux

I'm able to plot() in R from a regular terminal, but I can't do so from a tmux pseudo-tty. png() works fine but I can't write to the monitor.
UPDATE: Sorry, there's no error message. R merely fails to "print" to the monitor.
UPDATE 2: ctrl+b :showenv returns
DISPLAY=:0
SSH_AGENT_PID=1786
-SSH_ASKPASS
SSH_AUTH_SOCK=/tmp/ssh-ebteUtjL1719/agent.1719
-SSH_CONNECTION
WINDOWID=18928777
XAUTHORITY=/home/me/.Xauthority
fix in R
Sys.getenv('DISPLAY')
Sys.setenv("DISPLAY"=":0.0")
X11()
qplot(...)
.Devices
device.list()
should do it.
fix in tmux
You can also type Ctrl+b, :setenv DISPLAY :0.0 to change it from tmux rather than from R.
Why does this happen?
It might have to do with where you open the tmux (virtual terminal versus GNOME terminal) when you initially run the command tmux to initiate the session manager.
It's good to echo $DISPLAY in the terminal and Sys.getenv("DISPLAY") in R. See stuff like https://unix.stackexchange.com/questions/31283/error-in-r-unable-to-open-connection-to-x11
You can also run capabilities() in R and if capabilities()$X11 == FALSE then that's what to work on fixing.
I messed around for a while and then was able to do X11(); qplot( my.ggplot ). Check ?X11 for a little more information too.
It would help if you included the error message, but it sounds like your DISPLAY environment variable isn't set properly inside tmux. Issue echo $DISPLAY from outside your tmux session, and make sure DISPLAY is set to the same thing inside tmux.
You can use the update-environment command in tmux to configure tmux so that it automatically updates particular tmux environment variables with their values from the external environment. See the tmux manpage for details, or search the web for "tmux update-environment" for various other pages that describe this feature.

Resources