QPad64's (QInsightPad's) output window - kdb

How do I get the q script output to be displayed in QPad64's (QInsightPad's) output window. I am presently starting q and QPad 64 with the following .bat file :
set QHOME=C:\Q\q
set QINIT=C:\code\server.q
set PATH=%PATH%;%QHOME%;%QHOME%\w32
START C:\QInsightPad-2.2_FREE-x64\qpad64.exe
Result: q opens in cmd window, but all output from scipts run in Qpad show up there ( in cmd ) instead of in Qpad's output window. How do I fix this ?

Qpad isn't really designed to be used like that. You could redirect the stdout and read it in to view in qpad.
\1 qproc.log
Your scripts could then have output to the log as certain things are done like so:
1"tables_loaded"
// \n for new line
1"\nfuncs_loaded"
read0 `:qproc.log
"tables_loaded"
"funcs_loaded"

Related

How to simulate multiple enter key press of batch file execution cmd or windows powershell?

I have batch file which I want to execute, during execution it asks for user input twice to press enter key. I want to skip this completely either by simulating the enter key press or by somehow completely overcoming it.
Edit : I can't edit the bat file to skip the program asking for user input
I have tried echo | <yourfinecommandhere> but this just simulates one enter key press. I am unable to simulate multiple enter key press
In cmd simply group multiple echos. For example this will print 2 newlines to the pipe
(echo[& echo[) | command
echo( is the most reliable way to print a new line in cmd, but in this case echo[ is probably better. Space is significant here so there must be no space after [
In PowerShell it's easier. For example to print 3 newlines use
"`n`n`n" | command
Actually the above will print 4 new lines, because there's an implicit new line after the string. But that won't affect the output. If you want exactly 3 new lines then use
Write-Output -NoNewline "`n`n`n" | command

Using shell commands in knitr and displaying output

I am trying to implement shell commands in knitr and display the output in the knitted pdf document as shown here:
```{r shell commands, engine="sh"}
wc -wlmc en_US.blogs.txt
```
I am not sure whether this is even being evaluated, as there is no output.
just realized that I can call this with system(), which will print to device! Therefore,
system("wc -l en_US.blogs.txt")
will print to the display.
Use intern=TRUE to return result of system() as character vector, then cat with past and collapse. Example.
x <- system("tree", intern=TRUE)
cat(paste(x, collapse="\n"))
places tree of working directory in output document using knitr.

Matlab fprint function with GrADS scripting

I am using Matlab to print a small text file (temp_script.exec) that will be used to run GrADS commands. The script looks like the following:
'reinit'
'open temp_ctl.ctl'
'set lon -100 -80'
'set lat 20 30'
'define prc = var'
'set sdfwrite data_out.nc'
'sdfwrite prc'
The script is called via cshell:
#!/bin/csh -f
grads -lbc << EOF
temp_script.exec
EOF
exit
The script seems to execute properly, but the output (data_out.nc) is not generated. Strangely, if I edit it using VI and replace the first character -- the single quotation before the command "reinit" -- by typing another single quotation, then re-run the script, data is generated properly.
My question is, what could be different? The scripts look identical in several different text editors, but the "modified" script (by typing) is 1 byte larger. I am using the "fprintf" function to generate the single quotes in Matlab. Could it be some problem with that function?
Thanks for reading.
To see if the files are really the same (the generated one and the one edited with vi):
od -c -t x1 temp_script.exec > temp_script.lis
od -c -t x1 vi_script.exec > vi_script.lis
diff exec_script.lis vi_script.lis
There could be a UNICODE BOM at the beginning of the file, or a missing newline at the end of file that is causing your issue.

same input for interactive command in Perl script

In Perl script I am using command of unit(external command) using system
but that command need some run time input from user. Every time I want to give similar input which is stored in variable.
My command is:
system("dt ci $dest_file");
after this command my script is waiting for user input,
lets say I want to give "re base" as input to this every time
How can I give fix input every time it asks?
Please help, I am working on windows 7.
I want to make script completely automated... it should not wait for user input
If you call your script like this:
perl test.pl < input.txt
It should take the content of the file as an input. ( this is working with STDIN read )

Is there a way to tell if a default stream is open?

There is a line in a library that I can't take out:
put oResults format "x(80)" skip.
I have a program that is calling the library that doesn't have a default output so this line errors out.
I know I can just send output in my program somewhere but I want to fix it so you don't have to have a output. Seek function maybe?
EDIT: 10.2b
I only get an error in unix.
In a unix environment this line:
put oResults format "x(80)" skip.
errors out.
but if you put a:
if seek(output) <> ? then
put oResults format "x(80)" skip.
it doesn't error.
in a unix environment line:
put oResults format "x(80)" skip.
errors out.
but if you put a:
if seek(output) <> ? then
put oResults format "x(80)" skip.
it doesn't error.
You are running in batch mode. You should always be redirecting your output at the OS level when you run in batch mode. Something like this:
bpro -p test.p > errors.out 2>&1
Not redirecting output will pretty much always lead to the error that you are seeing.
If you are embedding the bpro, mbpro or _progres -b or whatever command in a script that needs to show that output or otherwise work with it you would typically use "cat" or "tail -f" on the output file.