Skip navigation.

exploreopera

| Help

Sign up | Help

NoteMe

- by Øyvind Østlund

Starting Opera and attaching Inspector in one go:

, , ,

I'd finally given it a go. 20 minutes of my life I never get back. I'm sure it can be done better than my first try, anyone up for a challenge?



Why would you automate such a task?:
When you are testing weekly builds of Opera on Linux attaching Inspector to Operas after it has started is one of those "jobs" you get tired of fast. Making a small application do it for you, or even a small script might not be as easy as it sounds like. You need to start Opera as a background process, to be able to attach Inspector afterwards, or you could make use of two threads where the second one is used to attach inspector to Opera. But non of them are very elegant solutions at all. While the latter one is probably closer to horrible. I'm no Linux guru my self really. But I do like the command line, even though I wish I knew much more about how to make it work with me instead of against me at times. And finding out how to both start opera and attach Inspector to the process in one line felt like an opportunity to both learn more, and once again read up on things I have forgotten since last time I used Linux on a daily basis.


What did I come up with?:

This is what I came up with after 20min back and forth:

./opera & ps -o pid= -o cmd | grep -m 1 opera | ../inspectr $(awk '{ print $1; }') &


I see three problems here.
  1. You can't have any other Opera processes running before entering this in a terminal.
  2. It uses 2 pipes. I have a feeling it should be possible using only one some way.
  3. It uses AWK. I have nothing against AWK at all. But it feels unnecessary. It might be possible for grep to find the right columns, but how do you know how many digits the PID is? Or does it even matter? That needs further thinking, and is what made me just ad the awk bit on the end as a lazy solution to it.


Where do we go now?:
I'm sure I can make it look better if I just look back at it with fresh eyes an other day when it is not so late. But if anyone have any ideas for improvements, or even totally different solutions to the problems. Then please comment on it. I'd be glad if anyone could teach me a thing or two about this. Am I missing something? Maybe it is possible to predict (read: query) what PID is the next one like a primary key in a database that would help a lot. Anyone?

Findar has given a solution like this in comment number one. Thanks to Findar for both saving me from finding the right answer as well as using unnecessary time on finding the right PID before attaching Inspector every time.


PS:
Mind the styling of the terminal. It will be all so much better first day of this year I get home from work before midnight.



- Øyvind Østlund -

Adding web-mail notification with Xfce and Opera:Navigating in Opera using nicknames and search:

Comments

avatar
Mayby you get inspired by this:
$ echo &
[1] 21616

[1]+ Done echo
$ echo $!
21616

$! referes to the last child pid

So all you need is:
./opera & ../inspectr $!

By Findar, # 9. January 2008, 08:22:40

avatar
So there is actually a way to find out the last pid. Even knowing that, I can't seem to get one search result about "&!" out of the first 10 on google. And the command is neither listed in the index page of the Linux book we had at university.

Thanks a lot. The solution is so short and elegant I am not sure even an alias is neded for this :smile:


Cheers,
- ØØ -

By NoteMe, # 9. January 2008, 11:37:58

avatar
well even though i kinda off topic...i consider myself very lucky, i've been testing opera weeklies for awhile now on windows and it never crashed on me. :smile:

By shadowk, # 13. January 2008, 13:28:21

avatar
That's hardly off topic, no need to be sorry.

If you look away from all the plug-in crashes for flash/Java lately on Linux, I can't say I have that many problems either. But I do get segmentation errors every now and then if I manage to reach the maximum number of files on Linux. I know I can just change ulimit, but I want to wait until I get some time to debug it more thorough so I can maybe get a good bug rapport on it. But I am quite good at procrastinating. Always 999999 things on my agenda.

PS: Quite surprised to see that 2600 has answered they are testing weeklies on the poll on the front page.

- ØØ -

By NoteMe, # 13. January 2008, 14:05:22

avatar
This attaches to the script and not the binary here:

./opera & ../inspectr $!

Looks like $! means 'last backgrounded process pid' and not 'last child pid'

remco@remco-serv:~/opera-installs/opera-9.50-20080110.6-shared-qt.i386-1754$ ./opera & /home/remco/inspectr/inspectr $!
[1] 31542
Using PID 31542

remco 31542 0.6 0.2 3832 1244 pts/5 S 14:59 0:00 /bin/sh ./opera
remco 31552 17.6 6.4 95540 33516 pts/5 Sl 14:59 0:04 usr/lib/opera/9.50-20080110.6/opera -style Plastik

By remcolanting, # 18. February 2008, 14:13:18

avatar
NoteMe, have you discovered google.com/codesearch yet? It's a great place to search the web for phrases reminiscent of comic book curses :wink:

By maximilion, # 23. February 2008, 15:35:13

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

Please type this security code : d29c4f

Smilies