BBOpen(X), current v1.23 (3/03)
BBA, current v1.23 (3/03)
This application will allow you to type in a terminal window "bba this.file" and have
bbedit open this.file without you having to use a FTP browser! It requires the use
of two files, one application goes on your Mac, and the other goes in your home directory
on our servers. There are 2 versions of the app, a carbonized one (BBOpenX) which works as a native
OS X app, and in OS 9.x if you have carbonLib. Also a PowerPC version
(BBOpen) for OSes previous to OS X, I know it works in 9.x and it
should work in 8.6 and up, but I don't know. The other file you need is a PERL script (bba)that
goes on the remote machine. Please let me know of any bugs or anything
you want added. I use OS X so the BBOpenX app will be the better working one since I'll be
using it all the time.
Installation
Put the app on your local Mac (BBOpenX or BBOpen), and start
it up. You'll see three pieces of information for you to provide and an 'ok' button.
- Username: This is the username you use to FTP into the remote machine, this
is generally your login name to that computer.
- Port: This is the port number that the remote machine and your local Mac will
communicate over. Pick a number above 5000 or so to ensure you're not using a port
already in use by the remote machine. This is the same number will be entered in the PERL script.
If the number in the app and the number in the PERL script differ, they cannot communicate.
- Secret #: In the long run, communication between the script and the app will be
very secure, but for now I figured a little security is better then none. Pick a number for
your secret number less then 2 billion, this number will also be put into the PERL script.
When data is sent from the script to the app, this number will be included, if they do not match
the app will ignore the request sent from the script. As long as you put the permissions as 700
on your script and THEN put in the secret number, the only way for someone to find the number
would be to sniff the traffic. Frankly, I doubt anybody cares that much, and this data isn't
sensitive at all. The only concern is that someone will find that you are listening to some port
on your local Mac and try to attack it, this provides a small amount of security. Think of it as a
wooden firewall.
Put the PERL script (bba) onto the remote machine. Chances are your home directory is included in your
$PATH (check by typing $PATH
at a command line). So if you put this script into your home directory you can just type 'bba' from anywhere
and it will work, otherwise you'll always be typing '/home/username/bba'. In the script there are 3 variables
for you to set. If its not, put it into your path, or check if /home/username/bin is in your path, if so, move the script there.
- $port: This is the port number that the remote machine and your local Mac will
communicate over. This is the same number that should be entered in the local app.
If the number in the app and the number in the PERL script differ, they cannot communicate.
- $secret: Pick a number for
your secret number less then 2 billion, this number should be the same as the one in the local app.
- $tmp_dir: This is a new feature, it stores temp files of each file you open. It adds a random number
to the name of each tmp file so you can have several temps of the same file. This especially comes in handy
when you pipe stuff to bba.
In BBEdit you'll need to have bookmarks set for the FTP servers you plan on using, to do this go to
'Preferences', and scroll to 'FTP settings'. Create bookmarks for each server you plan on using these
scripts from, also select the 'Remember bookmark passwords' button.
And your done.
Would you like to run BBEdit ftp transactions securely?
You can create an ssh tunnel to your server(s) and conduct the FTP transactions through
this tunnel, its easy. Open a terminal window and at your local command prompt type:
ssh -l [remote_user] -f -N -L [local_port]:[remote_server]:21 [remote_server]
example:
ssh -l ssmith -f -N -L 9999:myserver.com:21 myserver.com
For your local_port I suggest using something besides 21 (the reserved FTP port) as you'll have to run the command
as root and if you want to have multiple tunnels using 21 becomes moot, use 9999, 9998, 9997 or something.
You only need to do the "-l [remote_user]" part if the username on the remote machine is different
the your username on your local machine. The -f option tells the ssh tunnel process to go to the background after
it runs so you can still use the terminal or close it. The -N command tells ssh not to run remote commands
which means the ssh connection can only be used as a tunnel, no commands will be run. -L sets up the port forwarding
with the following arguments.
And finally, in the bbopen script on the remote server change "my $thisHost =" to:
my $thisHost = "localhost:[your_port]";
Where your_port was the local port you're forwarding on (9999, 9998, or whatever). If you're using the latest
script this line should be at the top of your script, if not, look for wherever the remote_server is defined and change
it to "localhost:[your_port]". Then, the first time you do this BBEdit will prompt you for a username for 'localhost'
type in the username you use to log into your local computer and you'll be set, it won't ask you again.
If you like, you can create a bookmark in the FTP prefs but thats unnecessary.
Usage notes:
-BBEdit must be open before this will work
-To open an file type 'bba this.file'.
-You can open a whole FTP directory in bbedit if you just type 'bba /pathtodir/', or just 'bba' in the dir
you want opened.
-You can provide a path too, 'bba ../this.file'.
If you 'bba' a file that doesn't exist, it will ask if you want to create it, if you answer yess, it will
create the file then open it in BBEdit.
-If you don't want your secret number or port to be visible, select the "I'm paranoid" option.
-To view a list of the files you've opened this session select the "Show List" option.
-If you click on a line in the list of files, that file will be opened.
*New*
-You can use globs now like, 'bba *.pl'.
-You can pipe output to bba using the '-p' flag like 'grep *.pl | bba -p'.
-This is an odd feature, but really helps me out so it may help someone else out too. If you provide a '-j' flag
to bba and a list of strings seperate by commans, 'bba -j site1,site2,site3 /path/to/site1/index.html' it will
substitue each of the items in the list into wherever the first item in the list appears in the path, confused?
-The above command would have opened these 3 files:
/path/to/site1/index.html
/path/to/site2/index.html
/path/to/site3/index.html
This is useful for openeing a file that has the exact same path, say in 3 different sites.
Not working?:
--The number 1 reason people can't get this software to work is because their environmental variable
$HOST is incorrectly defined. There is information on how to fix this at the top of the script. Essentially
if you type 'echo $HOST' and it says something like 'thishost' instead of 'thishost.thisdomain.org' you need
to change a line at the top of the script.
The PERL script says 'remote host refused connection':
--Do the PORT numbers match on the client and server?
--Is the BBOpen(X) application isn't running on your local computer?
--This can also happen if you open one file using and quickyly try to open another file, try to provide
the paths to all the files you want to open as one command.
--Sometimes, in rare occurances, the socket in the local bba app will close, just restart the app and it should
work again.
I typed 'bba thisfile' but nothing opened on my local computer:
--Make sure that the Secret #'s match.
Downloads/Updates:
If a update for the app comes out just download the tar file, if a update for the script comes out
before one for the app, just download the script.
BBOpen1.23.sit (script and classic app)
BBOpenX1.23.sit (script and carbonized app)
bba (just the script)
Things to improve:
Have it open BBEdit for you if its not already open.
Why does it not work with 5.1?
Put a status line in the application
Have multiple server-username matches
Build in C to lower file size (way later)
Make it secure using a ssh tunnel.
Version History
v 1.23:
- Added the use of globs to the bba script
- Added the ability to pipe text to bba
- Creates temp files of each file opened
- Detects username and remotehost now.
v 1.2:
- User information can now be hidden
- Can now provide absolute paths to files
- Log of files opened this session
- Can open files by clicking on file in the log
v 1.1:
- Accept paths to files
- If the file doesn't exist, ask if you want to create it, then open it
- Remember your username
- Still works if you close the app window
- The ability to bring the app window back after you close it