When running Octave in an interactive shell session, I know I can display character-mode / ASCII plots, as discussed here: Character-mode (shell) plots with Matlab / Octave?
My problem is that I'd like to have that kind of output when my octave script is run non-interactively. That is, I'd like to be able to run something like the following:
#!/usr/bin/octave -qf
plot(sin(0:7))
And have output along the lines of :
1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> + ---+ + + + + >
> +--- | >
> | | >
> | | >
0.5 >+ | | +>
> | | | >
> | | | >
> | | | >
>| + | >
0 >+ | | +>
> | | >
> | | >
> | + >
> | | >
> | | >
-0.5 >+ | | +>
> | | >
> +--- | >
> -- | >
> + + + + -+| + >
-1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1 2 3 4 5 6 7 8
I get that output if I open octave in the ssh session and then, at the octave terminal, call my script:
octave:1> testplot.m
But what I really want to do is to call testplot.m from other bash scripts, such as:
$ ./testplot.m
or
$ octave testplot.m
Neither of which actually give any plot output.
I have noticed that the interactive session output seems to scale automatically with the size of my terminal window, so in that sense it depends on the session.
Thanks for any assistance!
Clarification - I know how to create plots with figure visibility turned off, but I'm trying to avoid having to separately download plot files.
I also discovered this thread: Command-line Unix ASCII-based charting / plotting tool, but eplot seemed to give me errors (likely user error, bad data formatting, etc, but I don't know for sure), and I'd prefer to keep things in octave - octave already does exactly what I want as long as I'm in an interactive session!
All you have to do is to add a pause at the end of your Octave script.
Thing is, your script is already displaying the plot at the end but the program ends right after you you call plot, so the program exits and you don't even notice the plot.
In the picture below, I added the setting of graphics_toolkit and gnuplot terminal type, not because it's needed for your problem, but because on my system the default plot would be different.
Related
How do I stop the output being printed?
I don't want it to be like this
i=15
$1==15
I just want it to be processed without the output being printed
I tried looking everywhere and trying new lines of code and searching online and I couldn't find anything.
Set the right mode in your shell with:
/set feedback concise
There are four different mode for feedback you can use in jshell:
/set feedback
|
| Available feedback modes:
| concise
| normal
| silent
| verbose
Maybe you look at the various settings in shell with:
/help set
We are using Forge to import a STEP file into the modelspace of an output.DWG. Then a DLL combines modelspace geometry of several DWG files into several layout/paperspace of a single DWG. This sheet combination was working perfectly until just recently, when the combination process completely stopped happening.
Has something in Forge changed recently that we're not aware of? Updates/patches, or something like that which could have caused this issue?
This is an issue for a production application and is considered an outage at this point, and is very time-sensitive.
Edit: Here are some differences we noticed between the log files generated by this process. In this first section, the verbiage being written by AutoCAD has changed slightly during an extraction process:
[08/01/2019 17:15:35] End downloading https://.... 1556909 bytes have been unpacked to folder T:\Aces\Jobs\a43e5ca7faaa4db8b5374aaef71b36d3\cadlayouts.
[08/19/2019 17:25:53] End downloading file https://.... 1771363 bytes have been written to T:\Aces\Jobs\d12f3bed13b84d29b31226222e3cf3c9\cadlayouts.
In the log from 8/19, all lines logged in between:
Start AutoCAD Core Engine standard output dump.
And:
End AutoCAD Core Engine standard output dump.
Are being written twice, but this did not happen in the log file from August 1st or any of the logs before that date.
Edit 2:
Yesterday we used the .NET DirectoryInfo class to pull all directories into one list and all files into another and write them all to the log. The cadlayouts entity that should be recognized as a directory (because it's a zip that is extracted by Forge) is instead listed as a file. Our process runs a Directory.Exists() check before the work item merges the DWGs into the output, and this call returns false for the cadlayouts folder, bypassing our combination logic. How can the Forge zip extraction process be working correctly if the resulting entity on the file system is not considered a directory?
It sounds like you have an input argument that is a zip and you expect it to be unzipped into a folder. Please look row 4 in the table below. I suspect that this is what you are experiencing. There WAS a recent change here: we used to look at downloaded bits and unconditionally uncompressed if we found a zip header. (i.e. we acted identically for row 3 and row 4). We now only do this if you ask us to do it.
EDIT: The first column in the table is the value of the zip attribute of Activity's parameters while the second column is the pathInzip attribute of Workitem's arguments.
+---+------------+-----------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| # | Activity | Workitem | Arg direction | Comments |
+---+------------+-----------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 1 | zip==true | pathInZip!=null | input | Zip is uncompressed to the folder specified in localname. Any path reference to this argument will expand to full path of pathInZip. |
+---+------------+-----------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 2 | zip==false | pathInZip!=null | input | Zip is uncompressed to the folder specified in localname. Any path reference to this argument will expand to full path of pathInZip. |
+---+------------+-----------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 3 | zip==true | pathInZip==null | input | If zip is provided then it is uncompressed to the folder specified in localname. Any path reference to this argument will expand to full path of localName. |
+---+------------+-----------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 4 | zip==false | pathInZip==null | input | If zip is provided then it is left compressed. Any variable referencing this argument will expand to full path of localName. |
+---+------------+-----------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 5 | zip==true | pathInZip!=null | output | Workitem will be rejected. |
+---+------------+-----------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 6 | zip==false | pathInZip!=null | output | Workitem will be rejected. |
+---+------------+-----------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 7 | zip==true | pathInZip==null | output | Output(s) at localName will be zipped if localName is a folder. |
+---+------------+-----------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 8 | zip==false | pathInZip==null | output | Output at localName will not be zipped. |
+---+------------+-----------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
I have a CSV that needs to be converted to a simple new-line separated format to be fed into another script, but running into a weird issue.
Contents of CSV:
"1. ID","2. Height","3. Gender","4. Age"
"<1111111111>","5ft. 10.0in.","M"," 15.0"
"<2222222222>","6ft. 0in.","M"," 22.0"
Version 1 of CLI command:
cat source.csv | sed 's/[\"<>]//g' | ~/projects/dp/vendor/jq/1.5/jq --raw-input --compact-output 'split("\n") | .[1:] | map(split(",")) | map({"phone_number":.[0],"opt_in":"yes"}) | .[]'
Version 1 output: None
Version 2 of CLI command:
cat source.csv | sed 's/[\"<>]//g' | ~/projects/dp/vendor/jq/1.5/jq --raw-input --compact-output 'split("\n") | .[0:] | map(split(",")) | map({"phone_number":.[0],"opt_in":"yes"}) | .[]'
Version 2 output:
{"phone_number":"1. ID","opt_in":"yes"}
{"phone_number":"1111111111","opt_in":"yes"}
{"phone_number":"2222222222","opt_in":"yes"}
It's my understanding that the .[1:] tells JQ to only parse rows (separated by new line) past row #1, however row #1 will dictate references (being able to reference phone_number).
So why is version 1 not outputting anything?
Version 1 is missing the -s command-line option.
Another way to skip the header row is to use inputs without the -n command-line option, as follows. Using inputs is also much more efficient than using the -s command-line option.
< source.csv sed 's/[\"<>]//g' |
jq -cR 'inputs
| split(",")
| {"phone_number":.[0],"opt_in":"yes"}'
Robustness
Using jq to parse a CSV file is fraught with potential difficulties. In general, it would be better to use a "csv2tsv" tool to convert the CSV to TSV, which jq can easily handle.
I want to get a full control flow graph of a binary (malware) using radare2.
I followed this post from another question on SO. I wanted to ask if instead of ag there is another command that gives the control flow graph of the whole binary and not only the graph of one function.
First of all, make sure to install radare2 from git repository and use the newest version:
$ git clone https://github.com/radare/radare2.git
$ cd radare2
$ ./sys/install.sh
After you've downloaded and installed radare2, open your binary and perform analysis on it using the aaa command:
$ r2 /bin/ls
-- We fix bugs while you sleep.
[0x004049a0]> aaa
[x] Analyze all flags starting with sym. and entry0 (aa)
[x] Analyze function calls (aac)
[x] Analyze len bytes of instructions for references (aar)
[x] Check for objc references
[x] Check for vtables
[x] Type matching analysis for all functions (aaft)
[x] Propagate noreturn information
[x] Use -AA or aaaa to perform additional experimental analysis.
Adding ? after almost every command in radare will output the subcommands. For example, you know that the ag command and its subcommands can help you to output the visual graphs so by adding ? to ag you can discover its subcommands:
[0x00000000]> ag?
Usage: ag<graphtype><format> [addr]
Graph commands:
| aga[format] Data references graph
| agA[format] Global data references graph
| agc[format] Function callgraph
| agC[format] Global callgraph
| agd[format] [fcn addr] Diff graph
... <truncated> ...
Output formats:
| <blank> Ascii art
| * r2 commands
| d Graphviz dot
| g Graph Modelling Language (gml)
| j json ('J' for formatted disassembly)
| k SDB key-value
| t Tiny ascii art
| v Interactive ascii art
| w [path] Write to path or display graph image (see graph.gv.format and graph.web)
You're searching for the agCd command which will output a full call-graph of the program in dot format.
[0x004049a0]> agCd > output.dot
The dot utility is part of the Graphviz software which can be installed using sudo apt-get install graphviz.
You can view your output in any offline dot viewer, paste the output into an online Graphviz viewer and even convert the dot file to PNG:
$ r2 /bin/ls
[0x004049a0]> aa
[x] Analyze all flags starting with sym. and entry0 (aa)
[0x004049a0]> agCd > output.dot
[0x004049a0]> !!dot -Tpng -o callgraph.png output.dot
We're upgrading to play 2.3.5 and it's the first time I've used the activator.
If I run the activator headless, I can still pass in a bunch of command line flags, but if I try out the new UI I don't know how to pass in overrides for my developer setup (which are different from other developers). I don't see a way to set unique java properties in a meta activator config that we would exclude from version control.
-Dlogger.file=./conf/my-special-logger.xml -Dprop1=special -Dconfig.file=./conf/my-special-file.conf
I can symlink my-special-file.conf to application.conf and get most of what I want. It's not really an ideal solution and if I leave the symlink in place during bundling, the packager blows up.
[error] (*:stage) Duplicate mappings:
[error] ./my-project/target/universal/stage/conf/my-special-file.conf
[error] from
[error] ./my-project/conf/application.conf
[error] ./my-project/conf/my-special-file.conf
Typesafe Activator uses ~/.activator/activatorconfig.txt as a means of setting Java system properties.
With the following ~/.activator/activatorconfig.txt:
-Dhello=world
I could query for the hello property in the shell:
[play-new-app] $ eval sys.props("hello")
[info] ans: String = world
As a reference - this is for Play 2.3.5:
[play-new-app] $ dependencies
...
+------------------------------------------------------------+------------------------------------------------------------+--------------------------------------------+
| Module | Required by | Note |
+------------------------------------------------------------+------------------------------------------------------------+--------------------------------------------+
...
+------------------------------------------------------------+------------------------------------------------------------+--------------------------------------------+
| com.typesafe.play:play_2.11:2.3.5 | com.typesafe.play:play-ws_2.11:2.3.5 | As play_2.11-2.3.5.jar |
| | com.typesafe.play:play-jdbc_2.11:2.3.5 | |
| | play-new-app:play-new-app_2.11:1.0-SNAPSHOT | |
| | com.typesafe.play:play-cache_2.11:2.3.5 | |
+------------------------------------------------------------+------------------------------------------------------------+--------------------------------------------+