Is there any way to write a GUI under Ubuntu that one can work with gnuplot, octave and bash scripts together?
You'd have to make the GUI and call the scripts, be it octave, bash or gnuplot. You could probably make the plots in the GUI and forget octave. At the end I learned a little bit of ruby on rails to offer my fortran code on the cloud.
For example, You could use qt and call the octave function usino a system call. Or go web based and make an ajax call. There are just too many options, depending on which language/framework/libraries you use.
To make a script call from octave, see http://www.gnu.org/software/octave/doc/interpreter/Controlling-Subprocesses.html . There are many ways to do it. Depending on what you want, a mere
system("./my_script")
could do the job. If you need to get the response, there is info on that link. Otherwise, the script could put the output in a file that you could read later from octave.
If you want to get input in octave, so that you make something close to a very light weighted user interface, you could make a loop and inside ask for input. For example
while x>0
x = input("Enter an integer (0 for quiting), 5 for script")
if (x==5)
system("./my_script")
endif
endwhile
Related
Using the Turtle shell scripting library I am trying to launch a program, i.e:
shell "vim" empty
The problem is that this yields the warning Warning: Input is not from a terminal and causes Vim to lag for a few seconds before finally launching.
Questions:
Is shell the best Turtle function to launch an external program from haskell?
If so, is there any way to get around errors like the above?
You want to use functions from the process library, specifically createProcess or runProcess.
Relevant turtle thread on the issue here.
Example usage.
You could try manually setting up I/O to the vty. E.g. in bash: vim < $TTY > $TTY. I guess turtle is doing that with its own file descriptors under the hood, based on the warning, so you should be able to manually set up those redirects (or just use the command I gave via shell). You just need to make sure you've got a TTY environment var around.
Many terminal programs will behave differently depending on the STDOUT destination, either terminal or pipe or file. Usually they will remove colors. There are usually command line options for some of them to keep colors or formatting or anything else that is intended only for direct terminal output. But those options are not always present and it takes time to find them thus I need a generic way to trick the program so that it thinks that STDOUT is terminal, not a pipe. How to achieve this?
There are several tools for this, they basically create a pty for your command.
The best known is probably expect: http://expect.sf.net
Alternatively, empty: http://empty.sf.net
There are several examples in that page, have a look.
For simple cases, script -c 'mycommand' may be a viable alternative.
And tmux, which is powerful and pretty easy to script.
I've created a couple of very simple bash scripts for a home-made games arcade (input configuration, updating stuff etc). I've got a launcher, so it's not a problem to direct the user to run the wanted shell script, but while running a bash script functionality-wise gives me everything I need, the default low-res text-on-black look scares the end user.
What is the simplest way to "prettify" fullscreen shell scripts? Something that'll run the script in 1080p, use bigger bubbly antialiased fonts, add a fancy animated background etc., but still pretty much lets me stick to write good-old shell scripts?
I guess another way to ask is: Does a prettier, more modern GUI-looking alternative to whiptail exist?
I am running from the terminal, so the GUI library it would have to be as fully self-contained as possible.
The ability of a shell script to display a quit within the terminal window itself is limited entirely to the graphical capabilities of the terminal (and to what termcap/terminfo has support for).
Most terminals max out at 256 colors (though supposedly konsole has support for arbitrary RGB colors somehow).
Control over font sizing/etc. from the shell is limited to the escape sequences that the terminal is willing to respond to (and I don't know if those are at all standard or discoverable at runtime).
The best option for this might be to have your script re-exec itself in a new terminal window to which it passes appropriate arguments to control font selection, window geometry, color selection, etc.
That being said even reliably doing that isn't necessarily the easiest thing in the world (I'm not sure how portable the command line options are between different terminal emulators or how many more advanced features they expose).
You could use python with the library Gooey that makes easy to turn CLI applications to GUI:
It can be customized and it takes only one line for the magic to happen:
from gooey import Gooey
#Gooey <--- all it takes! :)
def main():
# rest of code
Hi I hope this question conforms to community guidelines. While working in Matlab I'd really appreciate if the command window had tabs (much like most terminal emulators in Linux). Is available in Matlab or do I have to run different instances of Matlab?
I am running a system which produces plots so running Matlab in text based mode via -nojvm is not possible.
EDIT: Is there a way to get such a feature or do I have to wait for Mathworks to wake up and implement this simple, timesaving tool.
Hmm I think the way Matlab works (with the workspace and the editor) tabs might not be that beneficial in terms of performance as opposed to just running a new instance of Matlab.
In Linux, you can fork new MATLAB instances with unix command and pass the MATLAB command you want to run as a command line argument. If you add & to the end of the unix input string, the new MATLAB instance becomes a background process, so this way from one MATLAB command window you can run commands (with output) in several MATLAB instances, opening a new MATLAB instance for command execution and output.
Here's the code:
multithread.m:
function multithread(MatlabCommand)
% this is a function to create a new MATLAB instance and run a command in it.
unix([ 'matlab -desktop -r ', MatlabCommand, ' &' ]);
return
testfunction.m:
function testfunction()
fprintf('one two three.\n');
return
Then you can run MATLAB commands in a new instance this way: multithread('testfunction');.
As far as I know, there is no such feature.
Although are you aware that you can use the -nodesktop flag to run Matlab in the current console and still have the ability to bring up plots?
Well - depends on what you plan to do with the tabs. You do have tabs for file editor, variable editor. But I suppose you mean command window.
I sometimes have two or more instances of Matlab open - one doing some calculation and doing some observation and quick stuff from the other - but I don't find it advisable.
I have found against using multiple instances that the preferences and path get "unusable" regularly (say once every month).
But as Matlab is "single" threaded - while it's calculating it's near impossible to do simple tasks as editing code or open a file in the same instance. If it had tabs i imagine it even worse. I think this problems lie very deep inside how Matlab works so that will not change very soon.
How to make a Linux program in the Command Line Interface who display a nice user interface?
For example when I use "wget" to download a file from internet, I can see the download advancement in the Command Line Interface. How can I do that?
ncurses is a popular option, there are APIs for lots of programming languages.
Take a look at curses. It is a library for text based UI.
You can get a basic interface by using \r to go to the beginning of the current line.
Slightly more advanced is ncurses.
The next step up is Newt.
If you want to do a GUI for Bash scripts or to wrap around other command line utilities, you can use dialog (man page).
Here two great dialog tutorial to get you started :
Dialog: An Introductory Tutorial
Improve Bash Shell Scripts Using Dialog.
If you only need a progress bar, this can be done directly with a simple print (that prints the bar), followed by the carriage return character (ANSI character #13), which puts you back at the beginning of the line. The line can then be later updated by printing over it.
For more complicated needs, ncurses is indeed the standard way to go.
I wouldn't call wget's progress report as a 'nice gui', but anyway, the classic library for building graphical interfaces without X Windows is Linux and UNIX systems is ncurses.
Recently a C# version of ncurses has been started, check out details here
If you're using Mono, you could use MonoCurses
Try curses, it is a well documented API for text based UI.Also, there is so much open source projects that are using curses for you see and learn
wget does not really have a GUI, all I see is stuff that you can already achieve using stdout and echos (e.g. printf() or std::cout)
Anyways, for simple dialog boxes of the MessageBox kind, but not limited to that, also have a look at dialog
http://linux.die.net/man/1/dialog
http://hightek.org/dialog/
You can just use ANSI escape codes. A simple example in bash
echo -e "\033[H\033[2J \033[20;20H \033[4mThis is a underlined line.\033[0m"
One should mention FTXUI. Functional Terminal (X) User interface: A simple C++ library for terminal-based user interfaces!
Cross-Platform
Support for UTF8 and fullwidth chars (→ 测试)
No dependencies
etc