Handy bash script
You’ve installed something from package repositories, and, on invoking, it tells you to actually run a certain script first. The script fails because you’re behind a proxy server, but you don’t know where Aptitude put the script in order to edit it. You know it’s in your $PATH, but that’s a lot of directories…
Solution (assuming you use bash):
for inMyPath in `echo $PATH | sed -e 's/:/\\t/g'`;
do
find $inMyPath -name MISSING_FILE;
done
MISSING_FILE is the name of the script (or whatever) that you’re after. This is fairly trivial, I admit, but it took me a while to work out how to do it right (mainly sedding PATH correctly). I’m about to put it into a script of its own for future use.
or alternatively:$ man which$ vim $(which MISSING_FILE)or even (assuming that the script is using wget)export http_proxy="http://wwwcache.cam.ac.uk:8080"export ftp_proxy=http_proxyIf not, send a bug report to the packagers.What are you trying to use, anyway? (for the record, I've never had that problem)
So in summary:"You're doing it wrong" As a general rule, if you find yourself doing some task more than once a month in unix, there will either be a command for it, or a 1-liner. Try asking in #ubuntu on freenode or something if google (add unix pr posix to your query).:D(*can't believe that which wasn't in unix in a nutshell*)
Asking in #ubuntu would probably still have taken as long as making the shell script, and I've learnt a lot more this way. Googling had already failed. I don't own Unix in a nutshell, only "Linux Pocket Guide". Which and whereis are in there, now I look, but I didn't know what I was looking for beforehand. As I made the command into a script in ~/.scripts (in my PATH) it became basically identical to whereis.The actual problem was in /sbin/get-iana, which was needed by firehol. wget had the –proxy=off option set, which is silly. I also had to alter the IANA_RESERVED variable to match what (I think) is what should be matched in the target text. I shall now try to submit a bug…
"As a general rule, if you find yourself doing some task more than once a month in unix, there will either be a command for it, or a 1-liner."…Or they expect you to script it yourself. Really, *nix kernel-and-core-utils developers can't and don't anticipate everything you might need to frequently do on the system. That's why bash has a half-decent scripting language in the first place.
Yeah, I suppose. That's why most people have ~/bin in their path (though that's mainly for installing stuffs that the system admin is too lazy to do globally).To be honest though, I only have a few things in my private bin, and only the last two are ever used from the console. most of the time, I just rely on ^R to help me with complicated one-liners.away # stop music, lock, and start cctvbed n # play music for n more minutes, then pausecctv # start motion, and bleep whenever anything movesintruder #helper function for cctv: just makes a soundmooddump.sh # for dumping moodbar files onto my eeepcserverup.sh # creates ls-lR.gz and ls-alR.gz on my server.quickfix file:n # opens file in vim at line n (file:n is a common form for error messages)dgrep # grep for dcop services, for helping me script kde
I love these notes, just letting them wash over me.
@David – I separate ~/bin (for actual binaries that I can't get from a repository) from ~/.scripts (for self-written scripts that do minor helpful things). Both are in my path. I still debate installing binaries in /usr/local/bin, though, which is arguably "better". Also, since when did you have a CCTV rig?@Tom: :p Hey, we're allowed to talk geek if we want… Nice to know you notice their existence, though!