PDA

View Full Version : Starting firefox from terminal



bizhat
August 21st, 2014, 09:19 AM
I have a bash script to start Firefox in different profile.



$ cat ~/bin/ff22
#!/bin/bash


firefox -P ff22 &
$


This works fine.

But problem is the terminal i run this program keep showing error message from firefox.

How i hide error messages from firefox showing in terminal ?

ofnuts
August 21st, 2014, 10:13 AM
Redirect stdout/sterr to /dev/null:



firefox -P ff22 > /dev/null 2>&1 &

ajgreeny
August 21st, 2014, 12:17 PM
Why not simply write another firefoxff22.desktop file to use as a launcher for that other profile?

Use command
gedit /usr/share/applications/firefox.desktop to open the original, look for the line
Exec=firefox %u
and edit that to
Exec=firefox -P ff22
then save the edited file to your /home as firefoxff22.desktop.

You could then move that new launcher to /usr/share/applications if you want to and you should then have the two versions of firefox showing in your menu or dash.

bizhat
August 21st, 2014, 12:38 PM
Thanks for the help. Got it working.

bizhat
August 21st, 2014, 12:43 PM
Redirect stdout/sterr to /dev/null:



firefox -P ff22 > /dev/null 2>&1 &


Thanks, this is what i was looking for :)

Edit: sorry for double post, i don't see option to delete/merge posts.

vasa1
August 21st, 2014, 12:50 PM
Redirect stdout/sterr to /dev/null:



firefox -P ff22 > /dev/null 2>&1 &

I use just 2>/dev/null
@ofnuts, please explain why you have > /dev/null 2>&1 &? And, why is there & at the end in this specific case?

bizhat
August 21st, 2014, 06:43 PM
& at the end because we need firefox run in background. If not, firefox won't release command prompt.

> /dev/null 2>&1

This, @ofnuts will explain :)

tgalati4
August 21st, 2014, 07:02 PM
It's bash magical shorthand for pushing Error Output (channel 2) into Standard Output (channel 1) and sending both of those into the bit bucket (/dev/null). It's used in a lot of bootup scripts to hide things when starting up services.


grep null /etc/init.d/*

bizhat
August 21st, 2014, 07:05 PM
It's bash magical shorthand for pushing Error Output (channel 2) into Standard Output (channel 1) and sending both of those into the bit bucket (/dev/null). It's used in a lot of bootup scripts to hide things when starting up services.


grep null /etc/init.d/*

Thanks,



firefox -P PROFILE_NAME 2>/dev/null &


Also worked with out any error message in terminal.

vasa1
August 22nd, 2014, 02:42 AM
& at the end because we need firefox run in background. If not, firefox won't release command prompt.

> /dev/null 2>&1

This, @ofnuts will explain :)

Got it. But you are running a script aren't you? From your original post:
$ cat ~/bin/ff22
#!/bin/bash


firefox -P ff22 &
$So just assign a keyboard shortcut to ~/bin/ff22 and you won't even need the terminal and & at the end won't be an issue. That's why I haven't found the need for & in my script.

bizhat
August 22nd, 2014, 12:41 PM
So just assign a keyboard shortcut to ~/bin/ff22 and you won't even need the terminal and & at the end won't be an issue. That's why I haven't found the need for & in my script.

Thanks, done that. Works much better now. Just switched from Windows, so still need to learn ubuntu tricks :)