certutil.exe is returning localized output - local

We have an PowerShell automation script that uses certutil.exe to list CA, issued certificates, etc... on a given Windows Server.
We wrapped some functions around a system Invoke of certutil.exe and we are grepping its output to look for some given patterns. However, in a French/German (and others for sure) installed Windows server, our script does not work at all, because certutil is returning localized outputs and it's impossible to predict that, and impossible to support all the languages of the world. Is there any way to force certutil.exe to print its output in English instead of the current machine language ?
I know that in Linux environment, we can do that:
LANG=en_EN.UTF-8 ls /tmp/toto
It will force ls to answer in English
Thanks for your help

Related

ComputerCraft Run Chat Command

I host a server and I was wondering: is there any way to run chat commands through ComputerCraft? I want to be able to run /tps through the ComputerCraft terminal and then have it print out the TPS. Help would be greatly appreciated.
Thanks.
In the new Computercraft 1.7 there is a new type of computer, the Command Computer. It allows the user to run commands the same way as shell.run("mkdir", "foo"). It can only be obtained by ops, and can only directly be controlled (we are talking without using rednet and such) by ops
commands.exec(string command) -- Runs and outputs command output in chat.
commands.execAsync(string command) -- Quietly runs command without output.
Here is the wiki page:
Commands (API)
But if we are talking 1.6.4 (Which almost all modpacks use) there is no "stock" version of doing that.
Hope it helps /Tyrerexus
I believe that you can use this thing called the Chat Box.
http://ftbwiki.org/Chat_Box
It's not part of the default Computercraft, however. It is part of the Misc Peripherals mod I believe.

Applescript: print first or other specific pages

How can you instruct an application or the printer to only print the first page, a page range or just odd or even pages of a file? I attempt this with the help of the Preview app, which looks promising:
set theFile to "[file-path/file]""
tell application "Preview"
activate
print theFile with properties {target printer:"Printer", ending page:1} without «class pdlg»
--these properties isn't available for the printer app, here just limiting amount of printed pages
quit
end tell
But with this I'm bitten by the sandboxd process that tells me the file can't be opened for printing and I get a deny file-read-data result in the log.
In the CUPS suggestion by adamh I encounter issues with umlauts and have other execution issues as well, possibly also because of sandbox rules. The code works from the command line, but not when called in automated fashion.
I tried to look up useful examples of the print command in a reference, in my books and tried searching the online Apple references, but I can't seem to find many examples fitting to the present day situation with sandbox, if any.
You could script printing by command line tool lp & lpr.
These talk to CUPS, Common Unix Printing System
To target pages / ranges:
lp -o page-ranges=2-4 "my_great_document.pdf"
To call it from applescript use do shell script
e.g,
do shell script "lp -o page-ranges=2-4 'my_great_document.pdf'"
For more ideas see: http://www.cups.org/documentation.php/options.html

How to set gnome-terminal's character set encoding according to the system one calls?

The employees of our company use gnome-terminal run from Debian workstations to access a variety of systems running different O/Ss on our local network. Everything works very well except that the host systems and their applications use different character sets, either ISO-8859-1 ("Latin 1") or UTF-8, and the server applications notably do NOT adapt to the locale of the user. This requires the user to manually set gnome-terminal's character set encoding each time one starts a new session!
(In case that's not clear, we always want to log into system X using ISO-8859-1, and always log into system Y using UTF-8. This has to do with the relative antiquity of the O/S of each system, the older ones having little or no accomodation of UTF-8 while the newer ones deal rather grumpily with ISO-8859-1.)
It seems to me that gnome-terminal's character set encoding should be associated with the system one's logging into instead of the system one's calling from. And that therefore, the character set should be one of the parameters that can be pre-set in the profile. This is the way other terminal emulators behave, notably the Windows and Mac emulators that we use outside the office.
But in lieu of configuring it in the profile (which is not possible), does anyone know a way of setting the character set encoding as part of a command line invocation of gnome-terminal?
I've been trying to solve this annoyance off-and-on for years... any solution would receive our eternal gratitude. :)
in the good old times, gnome-terminal support --disable-factory, you can set up for local editing files:
#!/bin/sh
export GDM_LANG="de_DE#euro"
export LANG="de_DE#euro"
export RC_LANG="de_DE#euro"
export LC_ALL="de_DE#euro"
gnome-terminal --disable-factory
or remote access to a linux-box:
#!/bin/sh
export GDM_LANG="de_DE#euro"
export LANG="de_DE#euro"
export RC_LANG="de_DE#euro"
export LC_ALL="de_DE#euro"
gnome-terminal --disable-factory --tab --title="Server1 DE" --command "ssh user#Server1"
Now at gnome 3.10 I get
... Option "--disable-factory" is no longer supported ...
So, I am with you and will keep looking ...
Mario
This worked for me.
LANG=en_US.iso885915 /usr/bin/gnome-terminal

send command to zebra printer xcode

How would I send a CPCL or ZPL command to a Zebra printer through an app?
These commands would be similar to ones used in ToolBox.
For example how would I send "! U1 getvar "allcv"" to a printer and get the results.
I am using the Link-OS ios SDK and already have no problems connecting to and printing to the printers.
Did you ever figure this out? It's quite simple in the *nix world. If you send commands to the lp port via cat or some such, the printer will simply read them in. Note that this must be done as root if you don't have permissions set up on the device to allow normal users.
$ sudo cat command_file.txt > /dev/usb/lp0
So, I'm not a C or C++ developer, but the idea is the same in any language. Open the file for writing (probably O_RDWR so you can read back in any response from the printer) and then send commands to the fd returned from open().
You didn't specify an OS so I'll just stick with this *nix answer. That said, it wouldn't be different in Windows, I suppose. You just have to be able to find the right device.

securely run linux command line app from asp.net mvc app under mono

We have an internal and external facing asp.net mvc app running under mono on ubuntu 10.04 LTS. There is also a complicated (native, not mono) command line app that users use on the same server. They log on via ssh to do this. We have the security for the ssh users pretty locked down, so they can't do very much other than run the command line app.
The users of these apps have to:
login via ssh to the server, run the command line app with whatever command line switches are required which then does some long running processing and puts a report in the db of the web app.
Login to the web app, then set some options for publishing a report via the web app.
The users of the apps want to skip step 1 and do it all in the web app. I am thinking of creating a service that regulary polls the db for command line app jobs to run. The jobs would be created by the users as desired in the web app.
The problem is, the users want a box in the web app where they can just fill in any command line options. But I don't want them to do something like this:
-a dothis -b dothis & rm importantfile.txt
...in case the user's credentials to the web app are somehow compromised. I want to make sure that only that command line app can be used and nothing else. I am thinking of preventing the characters ! | < > & / \ $ ( ) from being allowed, which looks like are not required by the command line app.
Is that good enough? Are there any other shell tricks I should know about? Should I take a different approach?
I really don't want to have to write some sort of parser for the arguments that the users supply, because there are a ton of them that the users like to use.
Instead of running the command line as a shell command (launching the shell to launch the program), can you launch the program itself as a new process? I believe that's what the answer here is doing: Execute a command line utility in ASP.NET . If the actual program is launched as a process, rather than a shell, then things like & or rm will just be arguments to the command line utility, which should be fine if the command line utility checks for bad inputs.
If that's not feasible (although it's probably the better option), replacing all single quotes with single quote escape sequences, then placing single quotes around each of the arguments (split the string with a space as the delimeter), could provide a similar effect. Instead of making sure you avoid all possible bad characters (; can be used similarly to & in many shells), you only need to make sure that the provided arguments can't escape out of the single quotes. (You might also want to check for single quote surrounded arguments beforehand, to avoid double quoting them, and don't cound escaped spaces when splitting up arguments, etc., so that the users can provide arguments that need spaces).

Resources