PDA

View Full Version : Simple shell scripting question


mahy
February 26th, 2007, 06:17 AM
Hi y'all i wanna make Opera start without the tray icon by default. This is my perception:

mv /usr/bin/opera /usr/bin/opera-mod

and then create another file named /usr/bin/opera looking like this:

#! /bin/bash

/usr/bin/opera-mod -notrayicon

This simple solution has one drawback, however. If i start Opera like this: "opera www.google.com", the URL is discarded. How do i have to modify the script to pass all arguments PLUS the -notrayicon option? TIA for any help.

Tomosaur
February 26th, 2007, 06:34 AM
Use this script instead:

#!/bin/bash

/usr/bin/opera-mod $@ -notrayicon


The $@ means "all arguments".

louis_nichols
February 26th, 2007, 06:39 AM
My bash scripting is not very good, but it would be something like this:
#! /bin/bash

/usr/bin/opera-mod -notrayicon $*
Or, if you only want to open the first address, use: #! /bin/bash

/usr/bin/opera-mod -notrayicon $1

So $1 is the first argument, $2 is the second and so on. $* stands for all arguments.

Tomosaur
February 26th, 2007, 06:41 AM
Opera takes the URL before the arguments. If you do it the other way around it won't work properly.

kaamos
February 26th, 2007, 09:53 AM
It would be easier to just modify /usr/bin/opera by changing the last line from

exec "${OPERA_BINARYDIR}opera" "$@"

to

exec "${OPERA_BINARYDIR}opera" "$@" -notrayicon

geakMonkey
February 26th, 2007, 05:42 PM
This should be an easy one: why am getting this error?

bash: alias: la: not found
bash: alias: ls -a: not found


I uncommented these lines in the .bashrc:

# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'

I only uncommented the standared installed .bashrc, what do I need to edit here?

Thanks

mahy
February 26th, 2007, 06:31 PM
It would be easier to just modify /usr/bin/opera by changing the last line from

exec "${OPERA_BINARYDIR}opera" "$@"

to

exec "${OPERA_BINARYDIR}opera" "$@" -notrayicon


wow, this is even better. it works. THX!

mahy
February 26th, 2007, 06:33 PM
This should be an easy one: why am getting this error?

bash: alias: la: not found
bash: alias: ls -a: not found


I uncommented these lines in the .bashrc:

# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'

I only uncommented the standared installed .bashrc, what do I need to edit here?

Thanks

The error messages seem weird. It should look like

bash: la: command not found

However, try to start your own thread next time :)