Starting Opera and attaching Inspector in one go:
Wednesday, 9. January 2008, 00:46:02
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:
I see three problems here.
- You can't have any other Opera processes running before entering this in a terminal.
- It uses 2 pipes. I have a feeling it should be possible using only one some way.
- 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?
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 -
$ 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
Thanks a lot. The solution is so short and elegant I am not sure even an alias is neded for this
Cheers,
- ØØ -
By NoteMe, # 9. January 2008, 11:37:58
By shadowk, # 13. January 2008, 13:28:21
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
./opera & ../inspectr $!
Looks like $! means 'last backgrounded process pid' and not 'last child pid'
By remcolanting, # 18. February 2008, 14:13:18
By maximilion, # 23. February 2008, 15:35:13