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
Related
I'm running a script inside of a terminal screen in a remote machine I ssh'ed in, so I can exit and enter terminal any time. I had thought that to pause the script, I'd just have to either send a ^Z command to the screen, or go into the screen and hit ^Z (or ^A^Z). But neither of them worked. All it did was that it paused the screen -r command I used to enter the screen.
I'm running on a device incapable of installing any dependencies such as reptyr, gcc, or apt-get. That's why I'm resorting to using screens to run/pause my script.
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.
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
Im running derby server from the command line on ubuntu. Problem is when i start it, it stays running in the terminal window, so it print all its logs straight to terminal. When i close the terminal window, the server shuts down. Is there anyway i can start derby from the command line, and then be able to close the terminal without shutting down the server?
You can suspend it with CTRL-z and run it in the background with bg and then disown %1 (or substitute 1 with the job number shown between the brackets in the suspend message).
Example...
$ bundle exec script/rails s
[1] + 14192 suspended bundle exec script/rails s
$ bg
[1] + 14192 continued bundle exec script/rails s
$ disown %1
$ exit
Another technique is to use your window manager. Set up an application menu item that starts the network server for you, with the various output redirected to files. Then start your server by choosing that menu item.
The main problem I'm having is to background a screen session from Hudson-CI. The shell steps are that I need to start a screen session from a script that is launched by another script. Heres' a simple test:
test.sh:
#!/bin/bash
myscreen.sh
myscreen.sh:
#!/bin/bash
screen -dm -S myscreen pingit.sh
pingit.sh:
#!/bin/bash
ping google.com
If I run ./myscreen.sh I get a screen launched that runs the ping continuously without a problem.
If I run ./test.sh, the screen is never started. I'm assuming there's something basic that I'm either forgetting or not understanding, but I can't figure out what. I thought this would work.
The real reason I want to do this is to have Hudson CI launch a continuous-test script which starts as a screen session so that it can continue in the background. What I'm finding is that the screen session terminates once the task is completed in Hudson.
Any ideas on why I can't launch a persistent screen session from a grand-parent script? Or any ideas on how to deal with this?
This is on OSX 10.6, with screen built from source (so it should work the same as linux I think).
If I run your test.sh, I get the error message
./test.sh: Zeile 2: myscreen.sh: Kommando nicht gefunden.
i.e. command not found. You'll have to write ./myscreen.sh, if the current directory is not on the path. (Is it for you? It should not.) The same is valid for the screen call.
Changing both files to
#!/bin/bash
./myscreen.sh
and
#!/bin/bash
screen -dm -S myscreen ./pingit.sh
I can start my screen without any problems.
I'm on Linux (OpenSUSE) with
$ screen --version
Screen version 4.00.03 (FAU) 23-Oct-06
here.
I don't know why I did not find the following references before, but these were the links that helped me solve the problem:
https://serverfault.com/questions/155851/run-gnu-screen-from-script
http://wiki.hudson-ci.org/display/HUDSON/Spawning+processes+from+build
There are 2 issues here - one of screen being persisted after being launched by a grand-parent process. The other that hudson terminates a session after it completes its task.
The screen problem is resolved by zombie'ing the process as follows:
screen -d -m -S myscreen && screen -S myscreen -X zombie qr && screen -S myscreen -X screen pingit.sh
The Hudson-CI problem turns out to be a bug that's easily resolved per the above link. The solution is to add BUILD_ID=something into the shell script. So if the test.sh script from above is actually the Hudson Build shell execute, then it would have to be changed to:
#!/bin/bash
BUILD_ID=dontkillthisprocess
myscreen.sh
Once both of these steps are implemented, things work fine.