More Info for April 2003 Power Tools Column

The April 2003 Linux Magazine Power Tools column, Transfer Tips, Part II, covers transferring and synchronizing sets of files automatically with ftp, sftp, and wget. Near the bottom of page 59 is an example of using wget -r to do a long transfer while you go shopping.

There wasn't room in the magazine to include all of my original column. Here's the part we omitted, starting with the wget -r example:

Mirroring with wget and cron (end)


You could start the next example over a dialup connection, then leave home to go shopping while the transfer completes and the modem shuts down. This example uses a script named ndown that's described in the next section, but you could do the same thing with a system utility or a script you hack.

$ wget -r; sleep 20; ndown

Command-line Network Control

Many Linux systems have a GUI button or menu to bring a PPP connection up or down. But command-line control of a modem is handier sometimes. The same can be true of a broadband network connection: if you don't run any local servers that always need to be on the Net, you could shut down the network interface while you aren't using it. (Unless you've got a firewall that you trust 100%, why take a chance of break-ins if there's a simple way to shut down the network when you leave and bring it up when you need it again?)

ndown ("network down"), shown in the previous example, can be simple to write but also very handy. Having a corresponding nup program to bring the network up lets you control it non-interactively: from a cron job, for instance. If your system has the /sbin/ifdown script to shut down a network interface, and PPP is configured so non-root users can control it, then ndown can be an alias that simply runs (for example) /sbin/ifdown ppp0.

nup.txt is a shell script that implements all of this and more. First, look through the script, be sure your system has /sbin/ifup and that you have access permission to run it. You may need to edit the script to fix pathnames and change features. Rename the file nup, make it executable (chmod 755 nup), then make a symbolic link to it named ndown (ln -s nup ndown).

If you use this script under the X Window System, it opens a small colored xmessage window while your network is up. It also makes a simple "lock file" that keeps you from accidentally bringing the modem up while it's already up. (You may want to hack the script to use more-sophisticated locking.)

Finally, you can use this setup from a GUI interface -- so you'll have modem control from a button as well as from the command line. The simple script nup-ndown.txt can be run from a button/launcher on your desktop. When the button is pressed, if the "lock file" doesn't exist, nup-ndown will run nup to bring up the modem; otherwise it runs ndown to shut down the modem. It's brainlessly simple, but it works well.

These scripts are from an old Red Hat 6.2 system, and they're a bit of a kludge. If you improve on them, please send your version to the email address below so I can share it.

[Back to articles page] [Home page]

Last change: 30 April 2003

Contact Jerry Peek