I need to run a powershell script from haxe code and return data. I will use this data in my code.
How I can do this?
You can run a sys.io.Process from Neko.
Check out the api docs
http://api.haxe.org/sys/io/Process.html
To see an example of how to use it, check this
http://code.haxe.org/category/macros/add-git-commit-hash-in-build.html
In your case it would look like this
var process = new sys.io.Process('powershell', ['any parameters']);
Note: I'm not sure if you really need powershell since you can execute stuff commandline with this.
I hope this helps!
Related
In my personal PowerShell profile that loads whenever I start PowerShell, I want to include a set of functions by calling a function.
So I want to do something like this:
function loadMyFunctions{
. \MyFunctions.ps1
}
Now, in MyFunctions.ps1 I have a function:
function bobtest{
write-host "My name is Bob Newhart."
}
I am able to load the script MyFunctions.ps1, but after that is loaded I am not able to call bobtest in the console - I get the error message The term bobtest is not recognized...
However, if I just load the script outside the function then that script is loaded and I can call bobtest normally - but that means that I can't just not load MyFunctions when the profile is loaded - I have to load MyFunctions and cannot choose.
You see, I want to load the other functions on demand and not have them available until I choose.
Is there another way to do this or can it even be done?
Have a look at this page, How to Create PowerShell Modules and Manifests.
This will enable you to create a module which will have all your custom functions! Then inside of your loadMyFunctions cmdlet add Import-Module NewModuleName.
This will enable you to use your cmdlets.
Hope this Helps,
Lachlan
Best way is to use modules. But still if you want to get in some different ways , then you can try with your approach.
See the below screenshots which I have performed.
I have a function addition which simply does addition and I saved it as funct1.ps1
Now I am calling the same function from another function of the other script just using dot source without using as module and it results me properly.
Funct1.ps1
Triggered the function from another function in another script .
Hope it helps...!!!
I often call the same commands in MongoDb command shell, for example :
db.user().find().pretty();
How would you store and call back this command ?
Ideally converting it to something like this :
db.findp( 'user' );
I believe this is NOT what your looking for, now that I read your question again: http://docs.mongodb.org/manual/applications/server-side-javascript/
Instead you are looking to modify the console in such a manner to make your life easier.
I should note, right now, that there is actually an extension which can do this sort of auto-formatting for you made by 10gen: https://github.com/TylerBrock/mongo-hacker
However if you wish to modify the files behind MongoDBs console a little more then you will need to do some manual labour.
There is a rc script in your home directory called .mongorc.js. In this file you can place any custom code you like (as #Asya mentioned) and it will actually become a command within the console.
In you rc file you could place a function like:
DB.prototype.pfind = function(col){
return this[col].find().pretty();
};
Or you could write:
DBCollection.prototype.pfind = function(){
return this.find().pretty();
};
Then you should be able to do:
db.pfind('users');
Or with the second command:
db.users.pfind();
Of course this method is for Linux, I am unsure about Windows, however, Windows should have an rc type script somewhere I believe.
I came across this link: Exit status code for Expect script called from Bash but it did not help me. As I was looking to get the exit status code from a command run remotely, I came across cpan documentation for Net::SSH::Expect 0.08 which has "collect_exit_code" and "last_exit_code" methods, which is exactly what I'd like to use today, however, I'm unable to find a suitable replacement when running 1.09.
I'd like to keep it simple, such as:
$ssh_devel_exp->collect_exit_code(1);
$ssh_devel_exp->send("sudo make");
if ($ssh_devel_exp->last_exit_code()) { etc. and so forth... };
But, I cannot think of a simple way to get the exit status when running a command through Net Expect without methods similar to these.
I do not believe switching to Fabric is the answer for this issue; this is a perl application and I need to stick with Perl.
Thanks in advance.
Did you tried to call the underlying expect object?
$ssh_devel_exp->{expect}->collect_exit_code(1);
$ssh_devel_exp->send("sudo make");
if ($ssh_devel_exp->{expect}->last_exit_code()) { etc. and so forth... };
if nothing else helps you could create a small shell script that execute your commands and report back the exitstatus on stderr.
How do you create a cron job in Kohana? I setup a regular controller which extends off the Controller_Base and I ran the command line:
/usr/bin/wget http://domain/controller/custom_cron
But I can't get it to work. It just doesn't execute. No error, nothing. I didn't put any special code in my controller ... just what I need to run my program. So if there is like a special command to call a cron job, I didn't add it (cause I don't know what it would be).
Also, I need it to make MySQL calls so I would need to include the db info and connection and what not (if it doesn't do that automatically). And I work off a custom model. How would I include that (if it doesn't do it automatically).
Thank you.
php /path/to/index.php --uri=controller/action/etc/etc
Calling it like this pretty much makes it act exactly like in a web environment. The only difference is the protocol for requests is 'cli'. You'll need to keep that in mind if you are generating links.
So if there is like a special command
to call a cron job, I didn't add it
(cause I don't know what it would be)
Daft question - have you added that wget command to crontab or similar?
If on the other hand you're looking to make a "poor man's cron", you could try creating a hook that runs on every page load and checks the last time the job was run, perhaps storing the last timestamp in a file or database.
I had to use cURL as my fire-this-script command in curl
Ex:
30 18 * * * curl "http://domain.com/controller/method"
php and wget didn't work, even when calling index.php and adding the uri as suggested above.
Also, FYI, Most transparent way to test this was just running the line from SSH manually to see what the results were. Once I confirmed it was working there, then I put it in the cron.
The title explains it already. I'm looking for a solution to compare screenshots taken with target.captureScreenWithName in a UIAutomation script to some reference images. This would be really nice to test some custom views.
Try to use free ImageMagicK for Mac. Starting from iOS 5 there is a new UIAHost.performTaskWithPathArgumentsTimeout(path, args, timeout) that allows you to run external task right from your tests. Simply running ImageMagic script using this functions with parameters you will be able to get image comparison results right from your test.
var result = UIAHost.performTaskWithPathArgumentsTimeout(path, args, timeout)
path - string to the image comparison script;
args - an array of parameters and its values for ImageMagicK utility like:
var args = ['param1', 'param1Value', 'param2', 'param2value'....];
More details for ImageMagicK:
http://www.imagemagick.org/script/index.php
UIAHost reference:
http://developer.apple.com/library/ios/#documentation/UIAutomation/Reference/UIAHostClassReference/UIAHost/UIAHost.html
It is impossible to do it directly from UIA, at least I didn't find any way to do this. All the screenshots are saved to the test result folder. You can then process them by any tool you like.
Check out Zucchini Framework. It wraps UIAutomation API nicely and lets you have screenshots as test assertions.