January 22nd, 2005
The problem
I usually work at the office, but occasionally work from home. At the office I can browse to any networked server in Windows (e.g. in Windows Explorer) by entering an address like \\networkedserver. When I'm working from home, I log on to my work network via an SSH session. This works fine, but one drawback is that, because it's not a VPN session my home PC is not part of the work network, so although I can access machines from a command line, using SSH, or upload/download files using WinSCP, addresses like \\networkedserver don't work because (unless "networkedserver" happens to be one of my own machines on my own home network).
How this affects my work
The only hassle this causes is when I work on structured FrameMaker files from home. I need to copy the source XML files from the server at work to my own machine (using WinSCP) and then modify them the path to the DTD, using a text editor. Once I've finished working on them in FrameMaker and I want to copy them back to the work server, I need to change the DTD reference back to one that works on my work network.
For example, at work the FrameMaker XML files I work with reference a DTD called mxDocBook.dtd. Let's say the path to this is //networkserver/mxDocBook/mxDocBook-DTD/mxDocBook.dtd. So the start of each XML file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter SYSTEM "//networkserver/mxDocBook/mxDocBook-DTD/mxDocBook.dtd" [
...
If I tried to open this file in FrameMaker on a computer on my home network I'd get an error message, because FrameMaker wouldn't be able to find the DTD file. So I have to change the identifier to something like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter SYSTEM "file:///D:/work/mxDocBook/DTDfiles/mxDocBook.dtd" [
...
Changing each file back and forwards could get very tedious, but there's a solution.
The solution: the changedtd shell script
I wrote a shell script that you can use to automate this process. The script (called
changedtd) contains variables called FINDTHIS, CHANGETOTHIS and FNAMEPATTERN. It looks for files in the current working directory that match the FNAMEPATTERN (typically *.xml) and performs a search/replace, searching for FINDTHIS and replacing it will CHANGETOTHIS.
If you want to use the script, copy it and edit the FINDTHIS and CHANGETHIS values to appropriate paths.
To run the shell script you obviously need a shell. I'd recommend installing Windows Services for UNIX 3.5 as the easiest way of getting a UNIX-like shell on a Windows machine.
You can download SFU 3.5 free of charge from:
www.microsoft.com/windows/sfu
Once you've got a shell, all you need to do is put the
changedtd file in a directory that's in your PATH, and then, in a UNIX/SFU shell, browse to the directory containing the files you want to change and run the command:
changedtd
View/download the script
View the script
To download the script, right-click this link and choose Save Target As or Save Link As.
Notes:
You might think it's a very long-winded script to do such a simple operation, but most of the verbosity of it comes from:
a) The parsing of the command line arguments. This allows you to run the script on a directory other than the current working directory and to recurse into child directories (if you dare).
b) The usage instructions, which you can read by running
changedtd -h.
c) You could of course very easily change this script to do a search/replace with any text you like on any type of file, just by changing the values of FINDTHIS, CHANGETOTHIS and FNAMEPATTERN.
Potentially similar posts
April 18th, 2009 at 8:56 am (#)
If you do not want to have it generated everytime, you can use a program called figlet (http://www.figlet.org) on the linux/unix system. It does not usually come installed as standard.
You can install it in ubuntu (for example) by apt-get install figlet
The result is that you can generate text using different fonts. Once this has been generated, you can add it into the banner for the ssh/telnet/ftp server.
-Cary
April 19th, 2009 at 9:29 pm (#)
Thanks for the tip Cary.
I hadn't heard of figlet before.