Unable to exit Guard when running on Windows - ruby

When running guard on Windows with bundle exec guard with or without -i option, I'm unable to shut it down without closing the terminal window, it just hangs and doesn't respond to Ctrl+C and nor I can enter any commands when running without -i.

Try CTRL+Break.
I have the same issue with stopping Webrick and this also works for that.

type exit :) This is how it is on OSX at least

Related

Headless firefox does not exist after screenshot

I want to use headless firefox to capture an image of a webpage on macos.
This is the command I executed: /Applications/Firefox.app/Contents/MacOS/firefox-bin -screenshot https://developer.mozilla.com
This is what I see in the terminal:
$ /Applications/Firefox.app/Contents/MacOS/firefox-bin -screenshot https://developer.mozilla.com
*** You are running in headless mode.
The problem is the firefox application does not terminated after the image is created. I can see a screenshot.png is already created in the directory I run the command, as seen in the following screenshot:
I have to kill the process by Ctrl-C at the end.
Is there any parameter I can pass to the executable to make it exit after the screen capture is done?
I think you would have to manually quit firefox once the screenshot is done. This command should work:
/Applications/Firefox.app/Contents/MacOS/firefox-bin -screenshot https://developer.mozilla.com; pkill firefox
Explanation:
";" will run the first command followed by the second, regardless of success
"pkill" will kill all currently running processes with "firefox" in the name

How to hide/quit terminal while program is still running in OS X?

I'm doing my project and I need to log keystrokes system wide in macOS. So, I turned over to GitHub and found Swift-Keylogger. The only problem is I can't quit the Terminal while the program is still running.
Is there any way to not to run this in terminal or closing the terminal window instead of creating a mac app like here.
Note: There are some mac app style executables in github but they are not providing the output I want and some need additional permissions.
Instead of running the executable like ./Keylogger use nohup ./Keylogger &.
You can quit the Terminal after executing the command.
To kill the Keylogger, run ps -e | grep "Keylogger" to get pid and kill -9 pid.
P.S. I thought of adding it as well as running at startup but I'm too lazy to update the repository.

How to tell Bash to not stop the simulations when ssh disconnects?

I am running some simulations on another machine via ssh. Here is what I do
ssh username#ipp.ip.ip.ip
Go to the right directory
cd path/to/folder
And then I just call my executable
.\myexecutable.exe
The issue is that every time the ssh disconnect, the simulations stops. How can I make sure the simulations doesn't stop on the other machine? Will I somehow receive potential error messages (assuming the code will crash) once I reconnect (ssh)?
You should launch a screen or tmux to create a terminal from which you can detach, leave running in the background and later reattach.
Further reading:
http://ss64.com/osx/screen.html
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/screen.1.html
You may also want to try out Byobu:
http://byobu.co
run your command as follows : nohup ./myexecutable.exe >nohup.out 2>&1 &
The & is to run the command in the background
The >nohup.out 2>&1 sends your stdout and stderr to nohup.out)
Note the '/' as opposed to '\' - which won't work on osx

Start and Kill the browser using Ruby

All,
I've got a problem which I need your help.
Using Ruby 1.9.3 in Windows, I'm starting a browser with the following command:
system('start http://www.stackoverflow.com')
I've tried getting the pid of the above system cmd in various ways like exec, Thread and IO.popen. But everytime I get the different PID which I assume the PID of the ruby process.
But I need the PID of the started browser, so that I can kill the browser once I finish my task at the end.
Note that I don't want to use Watir / Selenium or any automation tool.
Kindly help me on this.
Don't use start, it will spawn new window, open browser and then detach the window. Specify the browser path explicitly to solve the problem:
browser = %q{"C:\Program Files\Internet Explorer\iexplore.exe"}
pipe = IO.popen("#{browser} http://www.stackoverflow.com")
puts pipe.pid
Process.kill(9, pipe.pid)
Run start /? for help message of start command.

Running command in background using cygwin from Windows cmd

I use cygwin from my Windows command line, I've always done everything quite happily except being able to run something in the background (i.e. putting & at the end of a command).
Just to give you more context, I want to be able to start a Mercurial web server and still be able to keep using the command line window and even closing it without killing the server. For example:
>hg serve &
listening at http://localhost:8000/ (bound to *:8000)
>echo "Still able to do this"
Any workarounds to this?
I had a similar problem running Apache, finally I used cygstart, it's like CMD start:
cygstart --hide /c/apache/bin/httpd.exe
In this case, it will run Apache as an background proccess thanks to the --hide option
Found the solution:
start <command> /B
start is a windows command, do a help start for more info
Alternatively and for my case
hg serve --daemon
or
hg serve -d
will do the trick

Resources