From owner-freebsd-questions Sat Jul 6 10:33:20 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id KAA24952 for questions-outgoing; Sat, 6 Jul 1996 10:33:20 -0700 (PDT) Received: from battra.telebase.com (root@battra.telebase.com [192.132.57.100]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id KAA24947 for ; Sat, 6 Jul 1996 10:33:18 -0700 (PDT) Received: from wormhole.telebase.com by battra.telebase.com id NAA07979; Sat, 6 Jul 1996 13:32:58 -0400 (EDT) Received: from current.willscreek.com (root@current.willscreek.com [172.16.11.101]) by wormhole.telebase.com (8.7.4/8.6.9.1) with ESMTP id NAA22682; Sat, 6 Jul 1996 13:32:55 -0400 (EDT) Received: (from bmc@localhost) by current.willscreek.com (8.7.5/8.6.9) id NAA01056; Sat, 6 Jul 1996 13:32:54 -0400 (EDT) Date: Sat, 6 Jul 1996 13:32:54 -0400 (EDT) Message-Id: <199607061732.NAA01056@current.willscreek.com> From: "Brian M. Clapper" To: "Thomas S. Traylor" Cc: freebsd-questions@freebsd.org Subject: Re: How do you write to an executable (binary)? In-Reply-To: <76092049@toto.iv> Reply-To: Brian Clapper Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >>>>> "Thomas" == Thomas S Traylor writes: Thomas> Here's what I'm trying to do: Thomas> I have a program that will prompt the user for a value. I would Thomas> like to write that value to the executable (binary) file. (Using Thomas> open, lseek, write, close) Thomas> Problem: Thomas> When I open the file I get the following error: Thomas> "Error: Text file busy". The message number is [ETXTBSY]. Thomas> I'm able to do this with other OS. How can I get this to work with Thomas> FreeBSD? Any ideas or suggestions would be greatly appreciated. That means the executable is in use--i.e., someone's running it. If you have enough space on the file system, you can eliminate that problem this way: 1. Copy the executable to a uniquely temporary file in the same directory, and be sure to preserve the ownership and permission settings. 2. Update the temporary file with your value. 3. Unlink the original. 4. Rename the temporary to the original. Of course, this whole topic begs the obvious question: Why are you updating an executable in this way? ----- Brian Clapper ....................... bmc@WillsCreek.COM -or- bmc@telebase.com http://www.netaxs.com/~bmc/ ......... PGP public key available on request The first and great commandment is: Do not let them scare you. -- Elmer Davis