An Even Better Open in Firefox

Yesterday I blogged about the nifty little Open in Firefox script that I made. As it turns out, there is an even better way to this, using some fancy Quicksilver magic.

By using Proxy Objects in Quicksilver, you can gain access to the Current Web Page object. After making sure that you have activated the Open URL With... action in the Quicksilver preferences you are free to specify Firefox (or another browser).

Current Web Page → Open URL With... → Firefox

Once you have this working, you can set it up as a custom trigger. I set mine to the F1 key. Even better, this trigger is much more extendable than the script. You might not necessarily always want to open a URL in Firefox. Say you want to open a page in Opera. Just create another trigger, but leave out the item in the third pane.

Current Web Page → Open URL With... → "Leave this blank"

Now when you use that trigger, activate it with a hotkey (I used F2) and type in the first few letters of the browser (or program) you want the URL to open in.

Open in Firefox

I currently use Safari as my primary browser on OS X systems. Oftentimes I find that I either want to dissect a web page in Firebug or even just see what it looks like in Firefox. This is kind of a pain because it takes several steps:

  1. Open Firefox (one step with Quicksilver)
  2. Activate Safari
  3. Copy URL from desired website
  4. Activate Firefox
  5. Paste URL into Firefox.

I could probably consolidate these steps a little bit (by dragging and dropping the URL perhaps), but the point remains, this is an annoying process to go through every time I want to quickly check something out in Firefox.

Last week I put together a nifty little script in Automator to streamline this process. Basically, the script copies the URL from the active tab in Safari, opens Firefox and loads the page. I saved the script as an application and with Quicksilver it’s now just one step to activate the script.

For the most part, the script was pretty easy to set up. There is a built-in action to Get Current Webpage from Safari. There aren’t any scriptable actions for Firefox from Automator, but opening it is simple enough using a terminal command:

open -a Firefox.app

The only slightly tricky part about the script was getting the copied URL to automatically load when Firefox opens. After a little research I found that this could be simply passed as a parameter to the open command:

open -a Firefox.app $@

Perhaps some other Safari-lovers will find this useful. Enjoy.

Useful Shell Tricks

I just found this nice list of shell tricks over at UnixJunkie Blog. Most of them have to do with clever uses of SSH. This really would have come in handy back when I was trying to write a script that processed user tracking logs on our lab computers.

Using ssh in Script

I’ve been trying to write this script to roll over one of the log files on the lab computers. I also want it to copy the rolled file to our server. Now, I’ve already written two different scripts that accomplish this task. One resides on each computer and does the rolling task (I execute it on all the computers from ARD). The other is on the server and does the sftp bit.

Even though I’ve already got the working scripts, it’s of course not good enough. I’m accessing the remote computers in each script in one way or another. I’m also pretty much manipulating the same files. I should be able to combine the two scripts into one.

So, I wrote this script that combined both of the previous scripts. It has two basic parts. The first part uses ssh to log into the remote computer and does the following tasks:

Copy the log file and name the new one to include a date stamp gzip the rolled log file delete the old log file

The second part simply uses sftp to get the rolled log file.

Unfortunately, the ssh part of the log file just does not work. Clearly, the problem is that I just do not understand how to run ssh from a batch file (or at least not interactively). Here is the relevant part of the script:


echo "OK, starting ssh block"
for remotehost in $computer_list; do
 echo "OK, rolling log on ${remotehost}"
 ssh $remotehost <<EOF
  log_file=usertracking-${remotehost}.log
  new_log_file=usertracking-${date}-${computername}.log

  cd ${log_source:?"Directory does not exist."}
  cp ${log_file} $new_log_file
  gzip -fq $new_log_file
  new_log_file=${new_log_file}.gz
  rm $log_file
  echo "New log file name: ${new_log_file}"
  echo "Finished rolling log file"
EOF
done

This generates the following error after the ssh line:

Pseudo-terminal will not be allocated because stdin ↵
is not a terminal.

I pretty much understand what this error means, but have no idea how to fix it. After doing a lot of searching, I came up with this format for calling ssh:

ssh -v -q -o "BatchMode=yes" $remotehost

It doesn’t work for me though. At least, I don’t know how to use it. There is lots of information online about how to set up the authorization keys (which I’ve done), but not how to actually run it from a script. The stuff that I did find looked like it was written in latin.

So, after deciding that I was outmatched by the ssh batchmode, I decided I should try and write the whole thing just using sftp. Just one problem though, I can’t cp a file in sftp! There is no way for me to copy a remote file will using sftp. The only way I can think of to get around this is to GET the file, rename it on my local machine, and then PUT the renamed copy back on the remote computer. But, well, that’s just dumb. So, now I’m stuck. And grumpy.

Apple Remote Desktop – Send Unix Commands

I hit the jackpot of uxix command goodyness on osx. This stuff is so exciting to have in one place!

  • Apple Remote Desktop – Send Unix Commands

Via Team Apple of San Diego County.



appointive
appointive
appointive
appointive