Cancel command in Grunt that hasn't been launched - apache-pig

In Pig Grunt, if I make a mistake in my command (for instance not closing a '), it shows a new prompt until the command is fixed:
grunt> tmp = LOAD '/mapred/data;
>>
In the case above, adding '; would solve it, but sometimes the command is long and complex, and finding the culprit proves difficult.
Is there a way to cancel the current entry without exiting Pig altogether? I.e., not ctrl+C or ctrl+D?
Note: I know it's similar to this question how to cancel command in GRUNT shell, but in my case the command hasn't been launched yet.

Corresponding to your example, I realized one way of exiting is to complete the line which is open due to the single quote. Therefore in this case I added the following in the next line and it quit with an error.
>> ';
Not sure if there is an easier way to do this, more so because the grunt shell is still not very developed. In any case, I hope there is a better workaround for this soon.

Related

How allow only one python code process to run if same is executed at the same time

if I have two or more running python console applications at the same time of same application, but executed several times by hand or any other way.
Is there any method from python code itself to stop all extra processes, close console window and keep running only one
The solution I would use would be to have a lockfile created in the tmp directory.
The first instance would start, check for the existence of the file, create the file since it is not there, then run; the following instances will start, check for the existence of the file, then quit since it's there. The original instance would remove the lockfile as its last instruction. NOTE: If the app runs into an error and does not execute the instruction to remove the lockfile, you would need to manually remove it else the app will always see the file.
I've seen on other threads that some suggest using the ps command and look for your app's name, which would work; however, if your app will ever run on Windows, you would need to use tasklist.

Start a Spring-Shell based application not interactive

Is it possible to start a specific command of a Spring-Shell app and then return/exit the shell after the command is finished? Further is it possible to expose the exit code (System.exit) of the app to the operating system shell?
For my purpose i will take advantage of the plugin mechanism and the CLI-Annotations of Spring-Shell. But in general there is no human interaction with the app, instead a job scheduler (UC4) will start the app and check the exit code to generate an email in case of an exit code not equal to 0. On the other hand for manual tests by our customer, there is also the need of tab completion, usage help etc.
This behavior is already built-in (although we considered removing it, or at least make it optional). I see now that it is useful :)
Simply invoke the shell with your (sole) command and the shell will spin up, execute the command, and quit. Also, the return code of the shell already indicates whether there was an error or not (tried with an inexistant command for example). Of course, if your custom commands do not properly indicate an error (i.e. print an error message but perform a normal return) this will not work. You should throw an exception instead.
The behavior is back.
Run spring-shell with #my-script, like so:
java -jar my-app.jar #my-script
Where my-script is a file with your commands:
my-command1 arg1 arg2
my-command2 arg1 arg2

Read Output From A Running Process Realtime (Command Prompt)

I have been researching for an answer for my question for a long while using Google and changing what words I use in-case I find my answer, I have had no luck.
What I want is to the read the output from a process in real-time, not when it finishes the command it has been given. I have a command that I use which doesn't end unless the user ends it manually, closes the form or an error occurs. So every timer interval I would like to read the output from the command prompt (process).
I use background workers to start the process so it doesn't interfere with the form if that is any help.
Thanks in advance.

Get a return value from a screen'd command

I'm running a process in a screen (on Ubuntu 13.10, if it matters). I can execute a command within that screen with:
screen -p 0 -X eval 'stuff \"$command\"\015'
I'm not 100% sure what this command is doing to begin with, though it's functioning correctly. The reason behind it is I'm running a Minecraft server (still) and this screens in to the correct screen, and throws the command on the running command line. So that's good, so far.
But what I'd like is to be able to run this command with a return value. So for example, if I were to run a "list" command, it'd tell me how many people and who is online, but I need to capture that output and put it somewhere.
Anyone know of a way to accomplish this? I can't tell the minecraft server command line to redirect the output somewhere else since it doesn't have direct command line access, so the only way I could do this would be to grab all output of the screen while I'm connected ... but I'm not sure if that's possible.
I think you may be able to view the logs? can you not view a running log of the server ?

execute system command on rails - not working in production

On development everything works great. On production however, this line of code in a controller is no working:
output = `mclines #{paramFileName} #{logFileName} #{outputFileName}`
where mclines is a c program, and the rest are names of files. mclines is not executed on the production server, but it does on my laptop. I have no idea about what to fix. Have been trying different things for hours, but the truth is that I'm quite lost. In production the ssl in on, that's the only major difference.
If I execute the command on the shell, it gets executed. When I say it doesn't gets executed is because the first thing it should do is print some info in a file, and it doesn't. The server -as my laptop- is running ubuntu, but I have no idea about what logs could be usefull to read. systemlog had nothing usefull.
Any ideas that can lead to find the culprit are welcome.
Make sure mclines really exists on the production server, and use the full path to the mclines executable, as in
output = `/full/path/to/mclines #{paramFileName} #{logFileName} #{outputFileName}`.
Reference this
Try to print out your exit status code as:
$?.to_i
after the command...
or as pointed out in this link you can always use popen3/popen4 for better handling of input/output for system commands...