I am trying to print receipts on my Epson TM20ii using ESC/POS commands, sending them to the printer with out-printer' I have tried using both the epson driver and a generic text driver. My problem is that the printer is printing the command instead of executing it. See example
"LF" | out-printer -name epson
LF is the command for the printer to feed one line, instead of doing so the printer is printing the characters LF
I figured it out.
as some users commented, the commands are referring to the actual ASCII characters.
this however did not fully solve the problem as for some reason the powershell out-print command was sending the info to the printer in a way that the printer did not understand to be meant to be interpreted as esc-pos commands. The easiest solution that i found so far is a command line utility called RawPrint.exe which can be found here. The tool is very straight forward and i highly recommend it.
Related
I'm trying to write a PowerShell script to send data directly to Zebra GK420d label printer. "Out-Printer" produces endless count of pages and data not being sent to the printer.
Commands:
"data" | Out-Printer "ZDesigner GK420d"
or
Get-Content C:\barcode.txt | Out-Printer "ZDesigner GK420d"
result in producing print job with endless page counting and nothing being printed.
What worked for me was to share Zebra in my network and setting it up as lpt1 port:
net use lpt1: \\host\Zebra
I was able to copy a *.txt file with ZPL contents and it was interpreted correctly by the printer:
copy barcode.txt lpt1
That would work well as a work-around solution, but I'm trying to run this script on a server without admin rights. So sharing a printer or setting lpt1 cannot be done.
I want to be able to send data directly to the printer using PowerShell script, just like it can be done with "Print preferences>Tools>Action>Send command" or in Zebra Setup Utilities > Open Communication With Printer.
Any suggestions will be appreciated.
Inside of the Link-OS SDK there is a .NET SDK. This contains an command line exe which could be used from your script.
http://techdocs.zebra.com/link-os/2-14/pc_net/
Go to the link for "Use the command line"
I added new printer with "Generic \ Text driver" and pointed it to the USB002 port with Zebra printer. I can now use Out-Printer command as intended. Thanks for the answers.
Google provides an example of calling native executables here. The actual "executable" is a .BAT file which calls python. I wanted to see if I could just run a .bat file with some typical OS or maybe even PowerShell commands. According to the help the executable needs to return UTF-8 JSON so I replaced the call to python with the following command:
TYPE %~dp0\SAMPLE.json
Where SAMPLE.json is a UTF-8 file with some JSON content.
Needless to say it does not work:
Error when communicating with the native messaging host.
According to the help it could be because of message size or text vs. binary output modes. I know of no way to get a batch file to "talk binary".
Is there any way to get Chrome to talk to text based CLI utilities like batch files, powershell...?
I am running this command in powershell:
sqlplus system/passwd#mydb #my_sql
I have tried it with and without backticks and various other versions I found via Google. I keep getting an error when the command is passed off to sqlplus and have been unsucessful in finding the fix. Hopefully someone here can help out?
The error I get is:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SP2-0042: unknown command " ■#" - rest of line ignored.
So I am sucessfully connecting to the database but there is an extra character being passed to sqlplus in front of the '#'. " ■#" in notepad++ looks like " ¦#"
If you created your SQL command file using a redirect (> or >>) in powershell - like:
myProgram > mySQL.out
and then run it like:
&sqlplus mypw/myuser#mydb.xyz.com "#mySQL.out"
Powershell may have saved the output file in UTF-16 format, which Sqlplus does not like.
(You can confirm by creating the exact same file by hand and then comparing it - byte count will be off and in KDiff you'll get message to the effect that the text is equal, but the files are not binary equal).
To fix - you need to do two things: :
Add some blank lines to the top of your SQL commands - Powershell will still write a BOM (Byte Order Mark) there and it looks like it's pretty hard to get it to avoid that - but sqlplus will just go by it, albeit giving an error - but will move on to the rest of your code OK.
And then run this command in powershell before creating your file: $PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
See Changing PowerShell's default output encoding to UTF-8
I received this error:
SP2-0042: unknown command " ■S" - rest of line ignored.
and this fixed that - or at least I was able to run it. You can also just cut and past it from one window into another using Notepad++ and that will solve the BOM and encoding issue.
Update Problem Solved. This turned out being "not seeing the trees through the forest". I have been using these sql scripts for several years without issue called from a bash script. When I tried converting the bash script to powershell and ran into issues I blamed it on powershell. However; it turned out there was something corrupt in the sql file itself. There were no obvious errors when looking at the file in notepad++ even with show all symbols clicked and it was ANSI format. I determined it was the sql file itself when I manually ran sqlplus from a cmd window I still had the same error I was getting with powershell. I rewrote the script and saved it and the problem was fixed. I should have manually ran the script on day one and I probably could have resolved sooner.
I had the same problem. My issue was caused because the script file was saved as unicode. I don't know if this will help you or not, but here is how I fixed it:
Edit the script with notepad. Click File -> Save As. Change type from Unicode (or whatever) to ANSI, and save.
A couple of suggestions
Try the invoke operator:
&sqlplus system/passwd#mydb #my_sql
Try start-process:
start-process -NoNewWindow -FilePath sqlplus -ArgumentList #"
system/passwd#mydb #my_sql
"#
I had typical problem. The message was:
unknown command "and" - rest of line ignored.
The reason was an empty string in code.
e.g.
select ...
from ...
where ...
[empty string]
and ... < here was an error message
use as following
sqlplus -s system/passwd#mydb "#my_sql";
Finally found out how to make DbgPrint to really print in Win Vista/7 with:
ed nt!Kd_DEFAULT_Mask 0xffffffff
The problem is that there is some other drivers talking to the command prompt ni WinDbg. Is there a way to filter so only DbgPrint from my .sys file will reach the command prompt in WinDbg?
I know about DbgPrintEx but I'm not so into migrating my old driver with tons of DbgPrint to DbgPrintEx if there is an easier way for simple filtering...
Have you tried the .ofilter command? This filters at the host so it's not as fast as using DbgPrintEx, but it works in a pinch.
-scott
I have a lot of PowerShell script. One main, that calls other, child ones. Those PS scripts in their turn call windows CMD scripts, bash scripts and console applications. All these scripts and applications write messages to console. PowerShell scripts, for example, are using Write-Host scriptlet for this purpose.
Question: how can I easely redirect (send) all this console output to some file, while not deafening (canceling) this console output? I want to be able to see whats going on from console output and also have history of messages in log file.
Thanks.
You can use the tee equivalent of PowerShell : Tee-Object
PS: serverfault.com and/or superuser.com are more suitable for a question like this.
You can try Start-Transcript and Stop-Transcript. It has a couple of limitations like not capturing native exe output. It is also global to PowerShell session.
I've found script for grabbing console output: http://gallery.technet.microsoft.com/scriptcenter/e8fbffde-7d95-42d9-81de-5eb3d9c089e0. Script returns HTML to preserve colors.
The only big downside - you must call it at the end of your script to capture all console output it have made.
You'd probably need to write a custom host to do this. It's not a terribly hard thing to do, but it's does require some managed code.