IBM Message Broker running on linux needs to call windows executable. Can it be done? - batch-file

The scenarios is:
IBM WMB V8 running on linux has a list of user id's given to it in an MQ message. For each user id I need to connect to a windows box (samba share probably) and then pass this user id to a windows executable i.e.
C:\temp\command.exe 1234
C:\temp\command.exe 5678
the output from this command will return an image of this user from a database output to a directory.
WMB then goes and retrieves this image and somehow maps (user id => image) and updates a database somewhere.
Is this scenario possible in WMB without involving some other processor on the windows machine?
I can't see any nodes to help with this and I'm expecting i'll have to dump the userid list in a file and use perl or similar to process the command & image capture and return these to WMB as a message or something.
Regards,
Sapatos

Seems like a hard task. You can call arbitrary C-code and code custom nodes in C, so it's not impossible, since you could probably do most things with C and the Internet of libraries.
It seems like you would save yourself months of trouble by setting up a simple service on the windows box, for instance something listening to MQ, invokes the command then replies with the image.
You have not missed any thing. There are not any built in functionallity in WMB for this task. At least not when running on non windows platforms.

Related

How do I get bluez 5 to accept a fixed pin?

I can find nothing on how to do this. I am programming an Intel Edison in C and an Android phone in Java. I want to pair the Edison from the Android phone. I would think simple pairing (sspmode 1) would work but I get an error message on the phone about a wrong pin where no pin was requested. With sspmode 0 I get asked for a password but have no idea what it is as it is randomly generated in my NoInputNoOutput Edison. We have everything else working. If we pair from Edison manually, the rest of the code can connect and send bluetooth messages back and forth from the Edison to the phone. But pairing from Edison to any random phone that walks by is not acceptable. I think it is called Bluejacking.
I have seen some posts about using simple-agent but frankly what I understand is that BlueZ security changed so much between 4 and 5 that most all that I see doesn't work. I also see that the switch from 4 to 5 broke a lot of systems so I don't feel alone. I would try it but simple-agent is not on Edison and I have not found a procedure to install it. And as I don't know if the little I can find applies to version 5 as it all references version 4 I am feeling a little lost.
Can anyone point me in the right direction to something that will work on BlueZ 5? I am on 5.18.
The solution presented on the last post of this article does work
http://www.linuxquestions.org/questions/linux-wireless-networking-41/setting-up-bluez-with-a-passkey-pin-to-be-used-as-headset-for-iphone-816003/
Edit simple-agent, put it somewhere, make it executable, put the missing files in the same directory and run it. It must stay running for it to be active.
In my case, the missing file was bluezutils.py.
Run hciconfig hci0 sspmode 0 first
Pl use Bluz5.30.
Initially it was really difficult to bring up bluetooth using Bluez 5. It seems it was okay with Bluez 4.I have tried different versions of Bluez 5 on my LFS build. Even up to Bluez 5.28 it was not satisfactory. Now it is Bluz5.30, with this, LFS doc and lot of trail, I could manage. I feel Bluez is one of the most badly documented user unfriendly software. I also feel it is very buggy. It can hang machines forcing to hard boot the system. I have seen bluetooth forcing the Android phone also to reboot. So it is important to get the latest version of the software. But to make the bluetooth speaker work Pulseaudio was needed. It is better to get the latest version; here also LFS doc was fine.
So the process of connecting speaker was using bluetoothctl is as follows;
>> power on
>> scan on
>> pairable on
>> pair <device>
>> agent on
>> default-agent
Now the actual sound. Here pactl and pacmd are useful.
paplay -d can test the devices.
using pacmd with command 'list-sinks' can show the devices.
pacmd ->list-modules can show the modules loaded.
How to change automatically the audio output to bluetooth speaker when it is connected?
For me in one machine it was working fine, with an identical LFS in another machine it was not working. Finally it was identified as a
missing module module-device-manager with arg do_routing=1.
Once it was loaded everything was fine. This particular module was not shown in the pulse configurations. So I have to find that and load,
pacmd
load-module module-device-manager do_routing=1
One can add a line in the default configuration file available in /etc/pulse.or one can add it in the user configuration file also.Now to make the new bluetooth speaker being used to play sound. For that issue the command 'move-sink-input ' using pacmd. You can find the sink names my issuing the command 'list-sinks'.
If your speaker is not connecting, it may be that it is already connected elsewhere. If it is not so, remove-device; scan on; pair; and connect using bluetoothctl. I was worrying how to make file transfer using bluetooth (Bluez5). Actually very little information is available in LFS documention or in general in the NET. This very true and unfortunate about Bluez in general. They do not provide any real user doc or nothing is available in net. So the steps are as follows:
You need to install OBEX library. Then you build Bluez5 (if it not done already). It will install obexd. After installation you can find obexd in $PREFIX/libexec/bluetooth/obexd.This is where you find bluetoothd also. One generally makes a link for bluetoothd in /usr/sbin. A similar link can be made for obexd also. Once you start bluetoothd and obexd you can find object transfer profiles in bluetoothctl->show.If you need a phone to push objects to the computer, you need to run obexd with options '-a' and '-r '. if '-a' is not given phone will fail to send the file. Now how to push a file from Computer to Phone. For this you need obexctl, I do not think it is a finished tool, and it will not be installed while we build Bluez 5. I have seen it in the source tree and copied to /usr/bin/. It should be used to connect the Phone and when the connection is established one can 'send ' and you have to accept the request in the phone.
Starting obexd as a deamon was a problem. When obexd was tried on a text terminal (init 3) it was not possible to start since it needs a dbus session which in turn needs X display. It means one need to login an X seession before you start obexd. If you dissable X while building DBUS (--without-x) then Window Managers will not work. But there is solution with 'dus-run-session < command> [args]'. That means you can start a service obexd (like bluetoothd) in the system start-up. So just by switching on the Computer ( if pairing, trusting etc... was done earlier) one can push files from Phone to computer.
>> connect <device>
Second time onwards just connection is fine. Probably you can trust the device.
>> trust <device>

WPF app won't run in kiosk mode

I have a WPF application that is designed for a touchscreen kiosk. Users will not have access to a keyboard or mouse. The application runs fine when started normally from the program icon in windows. However, when it is set up to run automatically at startup (by replacing the Windows shell using a registry key), the application does not function properly.
The application reads an XML file that lists available videos, then displays buttons to show the videos. When run in "kiosk mode," it does not seem to have access to the files in its media directory (the XML file and presumably the videos as well). I suspect that because the application is running in place of the windows explorer, it is missing resources it needs for file access that are normally loaded by windows explorer.
I have not been able to find any info on this - there is plenty of info on how to get an app to run at startup, but not much on how to make sure it will actually function in that environment. The PC is running Windows 7 Professional.
Is my assumption about the problem correct, or is it likely something else (e.g. permissions - we checked the permissions, but maybe they operate differently when you replace the windows shell?) If it is because needed resources are not loaded, does anyone have pointers on how to make sure my app loads them?
Perhaps you have file access occurring via a file dialog? This might explain a bit further. What is the minimum functionality needed to create Shell Replacement for Windows?
because you have stopped windows default running explorer.exe , your program can not get access to default xml directory therefore you should specify the complete path for example like below:
stream = File.Open(#"C:\x86\Debug\xml.xml", FileMode.OpenOrCreate);

Cache Outgoing Data from browser

This might be a very broad question. But this is what i want. I open a website and enter some details in the website like my credentials to login or it may be any data that pass from my browser to the website. Now what i want is that i should cache ( write to a temp file ) whatever that i send to that website. How can this be done? I tried to extract the data present in the packets that are flowing out of my machine but i find only junk characters in that (may be header). any ideas are welcomed. I am using Ubuntu Linux and would like to achieve this using shell script/C/C++
One option would be to use the Fiddler Web Debugger which is scriptable (C#).
Although it's a Win32 program, it can act as a proxy for any Linux machine. See Debug traffic from another machine (even a Mac or Unix box) for details.
There's also a native Linux app called dsniff which can be used to log all HTTP traffic to a file.

WinAPI C - RunAsUser from REDMON_USER and REDMON_SESSIONID

I installed a PostScript printer driver and have setup REDMON (redmonnt.dll) for redirecting postscript output to my program. In my rather simple c program I capture the data from STDIN and I am able to successfully save it into a .ps file. The file looks OK.
However, I want to start gsview.exe for viewing the file. If I call ShellExecute it fails in Windows 7 because of permission issues. It seems that my program is called under a different user account (LOCAL SERVICE). So I am looking for a way to run gsview.exe under a specific username (the user who initiated the print job) which is available to the program in a variable called REDMON_USER along with the SESSIONID as well.
Q: What are the minimum WinAPI calls required to start a program given a username and a sessionid?
Any code examples in C/C++, .NET would be very helpful.
EDIT: What I am trying accomplish is something very similar to redrunee (from redmonee). I don't want to use redrunee because it opens about a console window for a brief moment.
Note:
1) The program is called by the printer service as [LOCAL SERVICE] account.
2) The first parameter Username (REDMON_USER), in effect, points to the user currently looking at the screen
Look at CreateProcessAsUser.
Also look at CreateProcessWithLogonW and CreateProcess.
They are linked from the CreateProcessAsUser
EDIT In reply to comments by OP.
Follow advice from this thread.
I am copying this here verbatim, in case the original link stops working:
The same code works for us on Vista as
on XP, etc. The service is running as
the Local System.
use WTSGetActiveConsoleSessionId to get the ID of the current active
Windows session at the console (i.e.
the machine keyboard and display, as
opposed to WTS sessions).
use WTSQueryUserToken to get the token for that session.
use DuplicateTokenEx(hToken,MAXIMUM_ALLOWED,NULL,SecurityIdentification,TokenPrimary,
&hTokenDup) to duplicate that token.
use CreateEnvironmentBlock to create an environment that you will be
passing to the process.
use CreateProcessAsUser with the duplicated token and the created
environment. Actually, we use
CreateProcessAsUserW, since the A
version had some sort of bug on some
older systems.
Don't forget to CloseHandle on the various tokens, etc, and to
DestroyEnvironmentBlock the
environment.
Thank you efratian.
PS. Oh joy of Windows programming, did not do it for quite a while. Now I remember why. The only thing that is close or even worse documented is OpenSSH programming.
The documentation describes the "Run as User" feature, which seems to be exactly what you want:
Run as User is intended for launching a GUI program such as GSview locally via RedRun.

RDP connectivity/responsiveness test

I want to write an app to test whether a Windows machine is responding correctly to RDP (Remote Desktop) - i.e. to check if the machine not only allows the connection, but is also responding normally, and is not hung or otherwise responding abnormally.
Is there a library or utility that I can use to do this? My searches turned up full RDC clients, but I'm hoping there's something out there at least offers an API for testing. I would most like to use Java or a scripting language to do this, but I'm open to suggestions.
You can find some good answers in this question: Programmatically create and launch and RDP session (without gui)
Because RDP is a constantly evolving proprietary protocol, i'm guessing there isn't some simple open-source code you can take and use. This leaves us with two possible paths to follow:
Use Microsoft RDP ActiveX control (on Windows)
Launch mstsc.exe and send keyboard events to it (also on Windows, using your favorite language)
For the second option, I suggest AutoHotkey. It is perfect for automating windows programs and comes with a powerful library. It also has a strong comunity behind it so you can find lots of useful scripts on the internet. I use it to control winamp (like 'i hate this song! delete it and move to next')(well, technically 'move to the next song and delete the previous' because you can't delete the file while in use but you get the idea). If you choose this path, i can help you with the script.
Found this on Experts Exchange:
use Net::Telnet ();
$t = new Net::Telnet (Timeout => 10, Prompt => '', Port >= 3389);
if($t->open("computer.name.or.ip")) {
print "Connect successful\n";
}
else {
print "Could not connect\n";
}
The idea was to attempt a connection and if it can't connect within 'x' amount of seconds, assume it isn't going to work. Gets a bit more complicated if you're trying to see if a login for a specific user works or not, but this should at least get you started.
NOTE: As pointed out in the comments, the original solution left out the RDP port, so I included that in this...

Resources