Home
Developer Resources
QNX RTOS v4
QNX RTOS v4 Knowledge Base

QNX RTOS v4 Knowledge Base

Foundry27
Foundry27
QNX RTOS v4 project
Resources

QNX RTOS v4 Knowledge Base

Title Setting up a cron script to transfer files using Net.fd
Ref. No. QNX.000009307
Category(ies) Utilities, Network, Configuration
Issue I use Net.fd to connect to a remote site via modem and enjoy the extra freedom this connection provides over a regular qtalk session. But to get even more out of this connection, I'd like to automate it with a shell script. I could use this script in conjunction with cron to transfer files during hours when phone lines cost less. Any tips on how to get started?
Solution Using a shell script, you can establish a Net.fd connection in a variety of ways-how you do it depends on exactly what you want to accomplish. But to get started, take a look at the following example, which shows one way you can connect two sites via Net.fd through modems. By the way, if you haven't read the Net.fd technote in /etc/readme/technotes, do so now. It'll help you better understand the example.

To set up the answering end, follow these steps:

1x09Set up the user ID netguy (or use any other appropriate name). You'll use this ID only for generating the Net.fd connection from a remote host.

2x09In the sysinit.node file of the answering node, enter the following command (note that both ends in this example use /dev/ser2):

x09tinit -t /dey/con -T /dey/con* -c 'modem -c "login netguy"'
x09-t /dev/ser2 &

3x09In /home/netguy/.profile, enter these lines:

x09Net.fd -f
x09exit

x09With these entries, the shell exits if Net.fd terminates, thus dropping the connection. Note that netguy must have appropriate permissions to launch Net.fd.

4x09Reboot your computer so the above changes take effect.

To set up the calling end, follow these steps:

1x09Create a shell script-let's call it net_fd.script-that contains the following command (if you use QNX 4.21 or later, see the discussion after step 2):

x09qtalk -x net_fd_establish net_fd_site

x09where:

x09net_fd_establish

x09x09A shell script that contains:

x09x09sleep 5
x09x09slay -f -t 'tty' qtalk
x09x09Net.fd -f /dev/ser2 &

The steep command gives qtalk enough time to make the outbound call.

x09net_fd_site

An entry in the /etc/config/qtalk file. This entry specifies the phone number and other info required to connect to the remote system. For more info, see qtalk in the Utilities Reference Supplement.

Executing net_fd.script will create a network connection between your local and remote sites.

2x09Set up a cron script that will:

x09•x09launch net_fd.script to establish the network connection

x09•x09copy files to or from the remote site

x09•x09slay Net.fd

x09•x09close the serial connection (i.e. tell the modem to hang up)

A simpler method for QNX 4.21 users

If you use QNX 4.21 or later, modem now has a -d option that will call out and establish a connection. As a result, you can replace the above qtalk -x command with the following:

x09on -t /dev/ser2 modem -d phone_number -c "Net.fd -f -"

With this command, you don't have to create the net_fd_establish script nor do you have to set up the net_fd_site entry in the qtalk file.
For more information on Net.fd and qtalk, see the Utilities Reference Supplement.