Start a groovy script directly from its url - command-line

I have a script that is available on the web, and I want to run it directly by entering its url, instead of downloading it and running later. Is there a way to do it ?

If you want to run a groovy script from a URL from the command line, you can do the following:
groovy -e 'evaluate( new URL( "http://yoururl.com/yourscript.groovy" ).text )'
Edit
Since Groovy 1.8.3, it is possible to do:
groovy http://myserver/myScript.groovy
Obviously care must be taken with doing this either way... Running stuff straight off the internet is never best advised ;-)

Related

WildFly CLI run script against embedded server

I have some scripts that I run using jboss-cli -c --controller=... --file=myscript.cli.
The -c and --controller options are great, because my script does not know which server it should be run against and can be reused for multiple servers.
I now want to use the offline-cli feature to avoid port conflicts and prevent servers from beeing reachable through the network while they are beeing set up.
My issue is now that in order to start an embedded server I have to use the CLI-command embed-server, but I don't want to add that command to my scripts, because the scripts are not supposed to know the name of the server config xml file.
Unfortunately I can't use both --command="embed-server --server-config=my-standalone.xml" and --file=myscript.cli at the same time, because the CLI complains with:
Only one of '--file', '--commands' or '--command' can appear as the argument at a time.
Another thing I tried was: --commands="embed-server --server-config=my-standalone.xml,run-batch --file=\"myscript.cli\" but this does not work either, because my scripts contain some if-else logic, for instance:
if (outcome == success) of /subsystem=iiop-openjdk:read-resource()
/subsystem=iiop-openjdk:remove()
end-if
And unfortunately conditional logic is not supported in batch mode (see https://bugzilla.redhat.com/show_bug.cgi?id=1083176).
the simple way is to start your embedded server in your script :
embed-server --std-out=echo --server-config=standalone-full.xml
/subsystem=messaging-activemq/server=default/jms-queue=inQueue:add(durable=true, entries=["/queue/inQueue","java:jboss/exported/queue/inQueue"])
/subsystem=messaging-activemq/server=default/jms-queue=outQueue:add(durable=true, entries=["/queue/outQueue","java:jboss/exported/queue/outQueue"])
quit
Don't forget to quit at the end of your cli script :)
If you are using a Unix system you may try something like this:
(echo embed-server --std-out=echo --server-config=my-standalone.xml; cat myscript.cli) | jboss-cli.sh

Opening a file in a Metro app from command line

I need a way to open a file in a Metro app from command line.
So far I've figured out how to start the app from command line without any third-party scripts
explorer shell:AppsFolder\Microsoft.Reader_8wekyb3d8bbwe!Microsoft.Reader
but I haven't been able to figure out how to include a file name yet.
Launching
explorer shell:AppsFolder\Microsoft.Reader_8wekyb3d8bbwe!Microsoft.Reader example.pdf
just opens up a default explorer window.
Any idea from Windows 8 experts on how to accomplish this without any third-party tools/cmdlets/etc.?
Note: In fact I'm using Windows 10 but I guess if there's a Windows 8 / 8.1 way to do it, it'll work for 10, too.
If you're still looking for the answer, the best way to open a file in a metro app is to use an execution string like a normal app protocol does. The execution string looks like this:
bingnews:[arguments, can be left blank.]
microsoftvideo:[arguments, can be left blank.]
netflix:[arguments, can be left blank.]
So, to start up netflix, it's as simple as typing in Start netflix: into the command line.
To find the execution string for an app, go here: Control Panel\Programs\Default Programs\Set Associations
More info and examples can be found here.
http://windowsitpro.com/windows-8/opening-windows-8-apps-command-prompt-or-script
http://www.itsjustwhatever.com/2012/10/28/launch-windows-8-metro-apps-from-a-desktop-shortcut-or-command-line/
PLEASE NOTE: To open an app WITHOUT A PROTOCOL (One not listed in the registry or under "Set Associations") use OP's method:
explorer shell:AppsFolder\[appuid]![appfullname]
The app UID is the folder name without the version number. For example,
4DF9E0F8.Netflix_2.11.0.8_x64__mcm4njqhnhss8
becomes
4DF9E0F8.Netflix_mcm4njqhnhss8
The app fullname is the [App author].[App name] For example, 4DF9E0F8.Netflix. 4DF9E0F8 is the author, and Netflix is the name.
Put it all together to get
explorer shell:AppsFolder\4DF9E0F8.Netflix_mcm4njqhnhss8!4DF9E0F8.Netflix
Store Apps can only be started by the shell. So try this:
explorer.exe shell:AppsFolder\Microsoft.WindowsAlarms_8wekyb3d8bbwe!App
Or from run (Win+R):
shell:AppsFolder\Microsoft.WindowsAlarms_8wekyb3d8bbwe!App
If the app is the default handler then you can just launch the file or protocol. There isn't a good in-box way to launch a file into a non-default handler from the command line.
Windows Store apps aren't designed to run from the command line and there isn't a straightforward way to launch them from the command line. Apps which handle specific files or protocols receive them through FileActivatedEventArgs or ProtocolActivatedEventArgs rather than command line arguments
You could write a launcher app which uses CLSID_ApplicationActivationManager's IApplicationActivationManager to ActivateForFile a specific app.
The best way I've found to pass command-line arguments to the executable targeted by the shell command is via the Windows start command.
Using your example, you would end up with this:
start "" shell:AppsFolder\Microsoft.Reader_8wekyb3d8bbwe!Microsoft.Reader example.pdf
I don't have Microsoft.Reader installed, so I can't test that. However, I can verify that this pattern works with Windows Terminal. In this case, I pass it a command-line argument to tell it which profile I want to open.
start "" shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App new-tab -p "GitBash"
The first argument to the start command here — the empty string — is just the title of the window.
You can also pair this with cmd /c, which I've found is necessary for some launcher applications, such as my personal favorite, SlickRun:
cmd /c start "" shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App new-tab -p "GitBash"
I have a blog post with more info on running Modern apps from the command line, which you might find helpful in constructing these ridiculously obtuse commands.
Not sure if it works on Windows 8, but on Windows 10 I use this:
cmd /C start <app-name>:
For example, to start Slack:
cmd /C start slack:

Perl command-line based script, running it on a website?

I have a Perl script that works perfectly when I run it from my command prompt. But when I upload it to the cgi-bin folder on my website, it doesn't work. Is there a special format it needs to be or something? I'm totally new to Perl.
Also note: the test hello page Perl script works.
When you run your perl script under cgi (which you indicated is working), the query is passed to your script as STDIN, and the output of your script is sent to the browser.
There will not be a prompt, or anything like that, you need something else (such as a web page) to prompt the user for anything you need and submit it to your script.
The next page on from Bill's link (http://www.lies.com/begperl/form_to_email.html) deals with this.

Executing a commandline from JConsole

I've recently discovered the joy of going through JConsole.exe instead of J.exe to run various scripts. There's generally a noticeable performance gain.
However, sometimes I need to use wd winexec (calling ad-hoc programs for example) and in the console, 11!:0 (wd) support is not available.
Is there a way to send a command from JConsole.exe to the regular Windows command line interpreter? Or maybe a workaround?
You might try the task script. See the script itself for documentation.
J6: ~system/packages/misc/task.ijs',
J7: ~system/main/task.ijs
It contains utilities such as fork_jtask_, spawn_jtask_, shell_jtask_
You can load the script in both versions using: require 'task'

Standard for feeding test data to a Nagios plugin?

I'm developing a Nagios plugin in Perl (no Nagios::Plugin, just plain Perl). The error condition I'm checking for normally comes from a command output, called inside the plugin. However, it would be very inconvenient to create the error condition, so I'm looking for a way to feed test output to the plugin to see if it works correctly.
The easiest way I found at the moment would be with a command line option to optionally read input from a file instead of calling the command.
if($opt_f) {
open(FILE, $opt_f);
#output = <FILE>;
close FILE;
}
else {
#output = `my_command`;
}
Are there other, better ways to do this?
Build a command line switch into your plugin, and if you set -t on the command line, you use your test command at /path/to/test/command, else you run the 'production' command at /path/to/production/command
The default action is production, only test it the switch indicating test mode is present.
Or you could have a test version of the command that returns various status for you to test (via a command line argument perhaps).
You put the test version of mycommnd in some test directory (/my/nagois/tests/bin).
Then you manipulate the PATH environment variable on the command line that runs the test.
$ env PATH=/my/nagois/tests/bin:$PATH nagios_pugin.pl
The change to $PATH will only last for as long as that one command executes. The change is localized to the subshell that is spawned to run the plugin.
The backticks used to execute the command will cause the shell to use the PATH to locate the command, and that will the the test version of the command, which lives in the directory that is now the first one on the search path.
let me know if I wasn't clear.
New answer for new method.