mkdir "/usr/employees" open "/usr/employees/larry" for output as file 1 print #1, "6/15/87 reprimanded for flaky behavior" print #1, "8/12/87 cruised in late after liquid lunch" print #1, "8/31/87 terminated" close #1creates and writes the file "/usr/employees/larry." Assuming that the directory "/usr/employees" did not exist previously, this program first makes the directory.
Note well that enchanting a program with a privileged status is hazardous to the health of a UNIX system, not only can a bug in the program reek havoc but if care is not taken, a set-user-id program can be used by an unauthorized and unscrupulous user to usurp control of the system. The shell statement is the best way to operate on directories, for example:
shell "mkdir /usr/employees"By this method, the privileged status is invoked only when it is necessary and risk of damaging the system with an omnipotent BASIC program is minimized. At the very least, this technique ought to be used while the program is being developed and replaced with the mkdir statement and privileged status only for the final version.
The importance of avoiding set-user-id programs owned by the super-user can not be overemphasized.
from The Basmark QuickBASIC Programmer’s Manual by Lawrence Leinweber