Does anybody know how to print out the message inside the OpenWRT preinit scripts? I tried with echo but all messages are suppressed.
Use preinit_echo and preinit_net_echo to output to the connected console. Use both, to cover both a local and a networked console, like:
preinit_echo "Message here"
preinit_net_echo "Message here"
(For discussion, see comments on OP.)
Related
When writing tests with dart:test how to print info messages such that they appear interleaved with tests output?
If I use print then it prints in the end, after all tests output.
Looking for analog of info() in ScalaTest.
After clarification with guys from the dart:test dev team it looks like regular print can be used. You just need to pass the --reporter=expanded argument when running
pub run test test/shimlaw_tests_test.dart --reporter=expanded
By default a compact single-line reporter is used which places output of print in the end of the test runner output. While the expanded reporter prints appropriately.
I am writing a small program in Progress that needs to write an error message to the system's standard error. What ways, simple if at all possible, can I use to print to standard error?
I am using OpenEdge 11.3.
When on Windows (10.2B+) you can use .NET:
System.Console:Error:WriteLine ("This is an error message") .
together with
prowin32 2> stderr.out
Progress doesn't provide a way to write to stderr - the easiest way I can think of is to output-through an external program that takes stdin and echoes it to stderr.
You could look into LOG-MANAGER:WRITE-MESSAGE. It won't log to standard output or standard error, but to a client-specific log. This log should be monitored in any case (specifically if the client is an application server).
From the documentation:
For an interactive or batch client, the WRITE-MESSAGE( ) method writes the log entries to the log file specified by the LOGFILE-NAME attribute or the Client Logging (-clientlog) startup parameter. For WebSpeed agents and AppServer servers, the WRITE-MESSAGE() method writes the log entries to the server log file. For DataServers, the WRITE-MESSAGE() method writes the log entries to the log file specified by the DataServer Logging (-dslog) startup parameter.
LOG-MANAGER:WRITE-MESSAGE("Got here, x=" + STRING(x), "DEBUG1").
Will write this in the log:
[04/12/05#13:19:19.742-0500] P-003616 T-001984 1 4GL DEBUG1 Got here, x=5
There are quite a lot of options regarding the LOG-MANAGER system, what messages to display, where the file is placed, etc.
There is no easy way, but in Unixen you can always do something like this using OUTPUT THROUGH (untested):
output through "cat >&2" no-echo unbuffered.
Alternatively -- and this is tested -- if you just want error messages from a batch-mode program to go to standard out then
output through "tee" ...
...definitely works.
The ZebraQLn220 has many settings that can be programmatically updated via commands sent it, such as:
! U1 setvar "media.sense_mode" "bar"
However, sometimes it takes several attempts before that change is "seen"/accepted/applied by the printer. For instance, I have sent the
! U1 setvar "power.dtr_power_off" "on"
command several times before this one:
! U1 getvar "power.dtr_power_off"
...will finally respond back with "on" (giving me "off" instead the first several times).
So: Is there a command that can be sent to the QLn220 that tells it to "flush" or "write all changes" or "save changes" or "I really mean it this time" or some such?
UPDATE
I don't know what firmware is new enough, but this is what the printer tells me about itself as far as "appl" settings go:
appl.date : 2/19/2014
appl.name : V68.19.7Z
appl.version : 6819
appl.bootblock : 2.5.9
appl.link_os_version : 2.0
If you are using later firmware you can use JSON to format the commands. In this method the commands will respond immediately with the configured values.
{}{"media.sense_mode":"bar"}
would respond with:
{"media.sense_mode":"bar"}
You can also put multiple requests in one:
{}{"media.sense_mode":"bar",
"power.dtr_power_off":"on"
}
The following knowlege base article has more info - https://km.zebra.com/kb/index?page=content&id=SO8638&actp=RSS
I'm trying to hack together a little CLI for Windows and, inspired by James Smith's Elixirconf talk, I was trying to use a Port to drive the interaction. So this is what I tried:
Interactive Elixir (0.14.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> p = Port.open({:spawn,"clip"},[:stderr_to_stdout, :in, :exit_status])
#Port<0.1048>
iex(2)> send(p,"This is a test")
"This is a test"
The "clip" utility simply takes whatever is piped into it and puts it on Windows clipboard. If you were to call it from the command line, you'd call it like this
dir | clip
So as far as I can tell nothing's getting to the clipboard via my test. I just wanted to ask if I'm sending the input to the stdio in the right fashion--I mean do I want to use send for that?
Interestingly if I do this:
p = Port.open({:spawn, "clip"}, [:stderr_to_stdout, :exit_status]) #Note no :in parameter
send(p,"This is a test")
I get this:
** (EXIT from #PID<0.45.0>) :badsig
I can't tell if the IO is actually getting sent to clip or not but I just wanted to confirm I'm doing the command correctly.
Windows 7 SP1
You don't need :in and you need to pass to the port {:stream, :binary} to be able to send to it bare strings.
Also try using port_command instead of sending to the port pid. http://www.erlang.org/doc/man/erlang.html#port_command-2
Although I am quite familiar with Tcl this is a beginner question. I would like to read and write from a pipe. I would like a solution in pure Tcl and not use a library like Expect. I copied an example from the tcl wiki but could not get it running.
My code is:
cd /tmp
catch {
console show
update
}
proc go {} {
puts "executing go"
set pipe [open "|cat" RDWR]
fconfigure $pipe -buffering line -blocking 0
fileevent $pipe readable [list piperead $pipe]
if {![eof $pipe]} {
puts $pipe "hello cat program!"
flush $pipe
set got [gets $pipe]
puts "result: $got"
}
}
go
The output is executing go\n result:, however I would expect that reading a value from the pipe would return the line that I have sent to the cat program.
What is my error?
--
EDIT:
I followed potrzebie's answer and got a small example working. That's enough to get me going. A quick workaround to test my setup was the following code (not a real solution but a quick fix for the moment).
cd /home/stephan/tmp
catch {
console show
update
}
puts "starting pipe"
set pipe [open "|cat" RDWR]
fconfigure $pipe -buffering line -blocking 0
after 10
puts $pipe "hello cat!"
flush $pipe
set got [gets $pipe]
puts "got from pipe: $got"
Writing to the pipe and flushing won't make the OS multitasking immediately leave your program and switch to the cat program. Try putting after 1000 between the puts and the gets command, and you'll see that you'll probably get the string back. cat has then been given some time slices and has had the chance to read it's input and write it's output.
You can't control when cat reads your input and writes it back, so you'll have to either use fileevent and enter the event loop to wait (or periodically call update), or periodically try reading from the stream. Or you can keep it in blocking mode, in which case gets will do the waiting for you. It will block until there's a line to read, but meanwhile no other events will be responded to. A GUI for example, will stop responding.
The example seem to be for Tk and meant to be run by wish, which enters the event loop automatically at the end of the script. Add the piperead procedure and either run the script with wish or add a vwait command to the end of the script and run it with tclsh.
PS: For line-buffered I/O to work for a pipe, both programs involved have to use it (or no buffering). Many programs (grep, sed, etc) use full buffering when they're not connected to a terminal. One way to prevent them to, is with the unbuffer program, which is part of Expect (you don't have to write an Expect script, it's a stand-alone program that just happens to be included with the Expect package).
set pipe [open "|[list unbuffer grep .]" {RDWR}]
I guess you're executing the code from http://wiki.tcl.tk/3846, the page entitled "Pipe vs Expect". You seem to have omitted the definition of the piperead proc, indeed, when I copy-and-pasted the code from your question, I got an error invalid command name "piperead". If you copy-and-paste the definition from the wiki, you should find that the code works. It certainly did for me.