How to run windows command in client side(accessing client machine using browser)? - plugins

I found many questions about same issue in Stackoverflow. But could not find any satisfactory answers.
My problem is:
I have to run "iperf client" in client machine(assuming windows) using command line in client windows machine and get the statistics.
Currently my server is written in PHP(I am ready to shift to any platform) given that I shall be able to run iperf command on client machine.
I searched and found that, Java applet, ActiveX control or Plugins(like Google Talk plugin). Can someone suggest me the best and easiest approach here(with some reference links if possible).

You cannot run an arbitrary command on the client side using Native Client. What you can do is invoke Pepper API functions from your extension. Another thing you can do is access the Chrome extension API from Javascript. If none of these have the information you need, feel free to suggest new features on the native-client-discuss mailing list. Note that invoking "any Windows command" cannot be reasonably made part of a client-side application, due to security issues.

Related

Controlling Google Chrome via Perl script

I was looking for a way to check for changes in a specific URL provided by the user. I wrote a script that I ran at home that can do that successfully using WWW::Mechanize. The thing is, I need to run it in another computer network that has a group policy that blocks all $mech->get($url) requests (it's not firewall problems, I let Perl through), so I thought I'll try and work around this problem by letting Perl control the web browser.
The computers in the network run Google Chrome and IE8 only and I can't install Firefox due to another policy (thought of using WWW::Mechanize::Firefox). I don't want to invoke IE8 in the script because most of the URLs that will be provided will be of websites that don't work well with it, so that leaves me with Chrome only.
Searching for a module that can do that, I only found AnyEvent::Chromi:
which exposes all of the Chrome Extensions API via a websocket connection.
This doesn't work (the policy probably blocks that websocket as well).
Is there another way to work around this problem/control Chrome from within a Perl script?
Is there another way to work around this problem/control Chrome from
within a Perl script?
WWW::Mechanize::Chrome
Like WWW::Mechanize, this module automates web browsing with a Perl object. Fetching and rendering of web pages is delegated to the Chrome (or Chromium) browser by starting an instance of the browser and controlling it with Chrome DevTools.
You can also do this from scratch without using any CPAN modules.
I tested this on Linux (Ubuntu 16.04, Google Chrome version 53) using Unix Domain (UD)
sockets. Unfortunately, it seems Windows does not have UD sockets, but
it should be possible to do same from Windows using named pipes.
First, make sure google-chrome is running in the background. We will
need to create a Chrome App
that will communicate
with a native host through the native messaging
API. The
native host can be any script that reads messages from its STDIN and
returns replies through its STDOUT. I tested both a Python
script and a Perl script.
Now, in order for a standalone Perl script to communicate with the
Chrome browser, it will send request through a UD socket (created by
the native host) to the native host; the native host will then
forward the request to google-chrome through its standard output
pipe. Then the Chrome App (written in JavaScript)
will receive the request. The Chrome App will use the Chrome
JavaScript APIs to get the requested data and return it to the native
host. Finally, the native host forwards the result through the socket to
the Perl script.
As you can see, there are some details required for setting this up, but I can
confirm that it works on my Linux platform. Please let me know if you need more
details.
Since you mentioned IE8, I'm assuming that you're dealing with a Windows system. And since you mentioned that you had considered WWW:Mechanix::Firefox, it sounds like you are not being restricted to just core modules.
Based on that, the only way that I can think of to automate the Chrome broswer would be to use Win32::GuiTest to control the Chrome browser. If you can figure out how to manually drive your testing using only keyboard input (i.e. no mouse), that would make things easier than trying to figure out the mouse emulation to get the cursor to the correct position for various tasks.
I'm not sure if that's necessarily a route that you will like to use or not. It's just the only way that I can think of to accomplish what you want to do with the restrictions that you have to deal with.

How to get started with vSphere 6.0 and set up the web client?

Linked from here
I've been tasked with setting up some VMs. I've been given some admin details but no further guidance. The server is a fresh install.
My problem is that I'm on Linux/OSX and don't want to run Windows aside from setting up after which I hope to be able to manage things through the web client.
I think there is an ESXi installation. This would be Version 6. How do I set up the web client?
I've installed vSphere Client on a local Windows VM.. not sure what to do with it though.
The documentation is pretty awful and there hasn't been much useful info on the net. I'm really stuck as I didn't set these up and haven't used servers like this before, so I have no context or understanding of the VMWare ecosystem beyond using a virtual machine locally! (even then I've preferred Virtualbox)
Any advice would be amazing
p.s accessing https://[ipaddress]/vsphere-client does not work. Produces a blank browser page... with no html served as an error
If you have the name of the server on which the VMs are stored, type this into the URL of a web browser then it gives you management options or alternatively use this login screen:

Is this a practical use of a service?

I need to run an application which processes hooks in background. The problem is that I have to start it automatically on systemstart as administrator. I've tried to use the windows task scheduler but on some systems it does not start the program as administrator which causes strange behaviours.
I've never written an windows service but would that be a solution to create windows service? And if yes: Does it start automatically as administrator on systemstart? How can i communicate with the service from an configuration program? And as last question: If I am right, I need to install a service through an installer like a msi-package. How would you create such a msi-package. Visual Studio 2012 does not support that anymore.
It would be very nice if someone could help me. Sorry for my bad English but I am giving my best. If you don't understand some parts of my question, just ask me.
1) Yes, this sounds a lot like you should write a service.
2) If you configure it so, by default they start with a special service account.
3) You can find a lot of good information about communicating with a service here: How to communicate with a windows service from an application that interacts with the desktop?
4) You don't have to. Do you use C# for example? You can then make use of a nice library called TopShelf to write your service.

Can you write Windows services in Powershell

I have written a program in PowerShell that loops and checks stuff.
I would like to convert this into a Windows service.
I've created a Windows service (in Admin->Services) but I can't start it.
I'm pretty sure I'm missing the proper interface that the system needs to call into in order to start/stop/pause/etc the service.
I can find plenty of examples when it comes to doing it in VB/C#/MS-lang but nothing about how to do it using PowerShell. Is there any documentation (or preferably code examples) out there to help with this?
There are a few items at issue here:
Are you sure that you really need a service? I agree with the comments about using the scheduler for running periodic tasks. The scheduler can start tasks as Administrator.
Services call a special set of APIs to communicate with the Service Control Manager, so an ordinary program can't be used directly.
The Service Control Manager uses CreateProcessAsUser to start the service process, so you need to point the SCM to an executable binary, as opposed to a script.
If you can't use the scheduler (though I strongly encourage you to try), I suppose that you could write an executable binary that acts as a service. It would then execute PowerShell and your script on your behalf. I'm thinking something like the srvany program that used to be included with the Windows Server 2003 Resource Kit could bootstrap the service for you.
If you absolutly want to execute your PowerShell code into a service, I think you can write a C# service wrapper for PowerShell code.
You found examples of how to create a service with C#, and it's simple to call Powershell from C#. So I'am surprised that as small SrvAny oriented PowerShell does not exists yet.
My advice here, you better rewrite your code in C# as a service.
You can use the Compile Script into Service option of PowerGUI: http://documents.software.dell.com/DOC144271
I think what you are looking for is SrvAny.exe from Microsoft (I don't know that they support it any longer, but it has been around in the Windows 2000 Resource Kit for years. It will essentially turn just about any executable (.exe, .cmd, etc...) into a service. I have VBScripts running as quasi-services using Srvany.exe and it works on Windows 2003 and Windows 2008 (even 64 bit). It is a little limited in that it does not provide 100% service functionality (stopping a running script may be difficult) but if you now a bit about programming and the Windows environment you can adapt it to work pretty well (i.e. it will launch the program after server Restart/Startup as you would likely need from a service. There is some documentation with SrvAny.exe (although it can be a little obtuse and difficult to find). It is however Free and built for Windows so it should work for you.
I agree for simplicity that the Scheduled Task idea is worth thinking about as it is even more simplistic that srvany.exe
http://www.firedaemon.com/
Will allows you start littery anything as a service. There are also free alternatives to this application, that does the same.

Something compareable to 'localtunnel' for Windows [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I found this here http://github.com/progrium/localtunnel , and it's exactly what I need, but I am working on Windows and localtunnel is Unix...
Some backgorund: I am currently developing a Facebook app and the Single-Sign-On won't work on my local Tomcat.
PageKite (disclaimer: I made this!) solves the same problems as localtunnel, but it is completely self-contained (written in Python, does not rely on ssh) which makes it very easy to install on Windows. Admittedly, you still have to deal with the command-line or at least edit the config file by hand, but a more user-friendly Windows GUI is in the works.
PageKite is free software (both the client and server) for those who want to DIY, but it's also backed by a start-up which provides all the service you need to get up and running in minutes.
A Windows client:
localtunnel for windows
Expose instantly your local webserver to the internet! See main project for more info...
UI Features
Custom service host setting
Win7 Jumplists for quick tunneling
Public key autogeneration
Specify a different host address than 127.0.0.1...
Just install ruby, then run the same commands. I just did that and works on Win7 x64.
Create an ssh key (make sure you don't already have one and will overwrite, for GitHub, etc).
ssh-keygen -t rsa -C "your_email#youremail.com"
Then upload your key to localtunnel (I had to enter my passkey setup in step above)
localtunnel -k c:/Users//.ssh/id_rsa.pub [server port]
I wrote up a description of how to get localtunnel up and running on windows via CygWin.
http://blog.wearemammoth.com/2011/09/localtunnel-windows.html
-m
edit:
apparently this link is broken - here's the cached version
http://webcache.googleusercontent.com/search?q=cache:lcJq2KO-ODoJ:blog.wearemammoth.com/2011/09/localtunnel-windows.html+&cd=1&hl=en&ct=clnk&gl=us
and here's the content in case that disappears too:
We recently integrated with the awesome Twilio service for a small project we developed. Like many of today’s APIs, Twilio offers a number of webhooks that alert you to changes on the Twilio side. This simple but great concept really opens up a lot of possibilities for API users everywhere, and I’m glad to see it spreading. Unfortunately, webhooks by their very nature require that you have a publicly accessible URI for the service to callback to, which makes developing your webhook handler a little bit difficult when you’re working locally. Enter localtunnel, a nifty little tool that makes localhost visible to the rest of the world and lets you build and debug your webhooks on your development environment without having to worry about publishing your changes every few minutes to a public site.
Unfortunately, if you’re developing on Windows, localtunnel won’t work quite as easily out of the box as it would for Mac and *nix users.
Here at WAM, we mainly develop on Microsoft’s .NET platform, which acted as a barrier to our ability to use localtunnel. Since the tool was attractive enough to warrant spending a little time setting it up on my Windows environment, however, I dug in my heels and figured out the general steps needed to get it working.
Rather than go through the number of misguided steps I followed due to my own unfamiliarity with the tools localhost relies on, I’ll cut to the chase and explain what I eventually set up to get everything working together.
First, install Cygwin. During installation, make sure you opt to install dev tools – you’ll definitely need at least Make, gcc, SSH and Ruby.
Download and unzip RubyGems into a folder that you can access under Cygwin.
Install RubyGems by changing to that temporary directory on your Cygwin bash prompt and running:
ruby setup.rb
Install localtunnel by running:
gem install localtunnel
Generate a public/private key by running.
ssh-keygen
When it prompts you for a file to save, enter nothing and press enter. It will put the file into your home folder. ‘~/.ssh’ and the path to the file is ‘~/.ssh/id_rsa.pub’ by default.
Make note of where your public key is saved.
Run localtunnel for the first time by running
localtunnel -k {Path_To_Your_Public_Key} {PORT_NUMBER}
For example
localtunnel -k ~/..sh/id_rsa.pub 8080
This will upload your public key to localtunnel and respond with something like
This localtunnel service is brought to you by Twilio.
Port 8080 is now publicly accessible from
http://3ivy.localtunnel.com ...
From then on, you can just run
localtunnel 8080
And get a temporary public URL for your local app.
One thing to note is that I had to use a port like 8080 to get it to work – something like 49581 wasn’t working and rather than fiddle with it anymore, I just set up vs.net to always build my local project to port 8080.
As always, your mileage may vary and this comes with the standard warning that this worked for me, but may not for you.
Good luck!
Somebody is working on a Java version of the localtunnel client, so stay tuned! Otherwise, no, I don't think other than setting up your own SSH tunnel there is a Windows alternative.
http://www.stunnel.org/
Stunnel is available for win32
A