Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Nov 1999 00:27:59 +0300
From:      "Oleg V. Volkov" <rover@lglobus.ru>
To:        freebsd-questions@freebsd.org
Subject:   Re: Is there correct way for program to read from itself?
Message-ID:  <19991119002759.B63288@fly.lglobus.ru>
In-Reply-To: <19991118154736.22915@mojave.sitaranetworks.com>
References:  <19991118065815.B89755@fly.lglobus.ru> <19991118102421.09370@mojave.sitaranetworks.com> <19991118223426.A62913@fly.lglobus.ru> <19991118152324.37840@mojave.sitaranetworks.com> <19991118232846.A63288@fly.lglobus.ru> <19991118154736.22915@mojave.sitaranetworks.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Nov 18, 1999 at 03:47:36PM -0500, Greg Lehey wrote:
> On Thursday, 18 November 1999 at 23:28:46 +0300, Oleg V. Volkov wrote:
> > On Thu, Nov 18, 1999 at 03:23:24PM -0500, Greg Lehey wrote:
> >>>>> Is there correct way for porgram to read from it's own file?
> >>>> I'm not sure I understand.  What do you mean by "it's own file"?
> >>>> If you mean the object file, sure.  Where's the problem?
> >>> I mean this situation:
> >>> I have some program /usr/local/bin/someprog. Is there a way for it
> >>> to read from itself (from /usr/local/bin/someprog).
> >> Sure, that's what I said.  What do you expect to find?
> > Could you give me short example?
> OK, here's copyme.c:
> 
> #include <fcntl.h>
> #include <stdio.h>
> #include <string.h>
> #include <sys/stat.h>
> 
> extern int errno;
> 
> main (int argc, char *argv [])
> {
[skip]
>   }
> 
> And here's what happens when I run it:
> 
>  $ copyme foo
>  $ cmp copyme foo 
>  $ ls -l copyme foo 
>  -rwxrwxrwx  1 grog  eng  4197 Nov 18 15:44 copyme
>  -r--------  1 grog  eng  4197 Nov 18 15:44 foo
>  $ 
> 
> Not much use, is it?  Was that your class assignment?

Heh, and now put it into PATH...
and

$ copyme foo
Can't open copyme: No such file or directory

Everything is not that easy.

--  
Oleg V. Volkov aka Rover                                         EH: LCM Rover
Join Elite Imperial Fleet!			 http://www.emperorshammer.org
E-mail redirector: sr-13@mail.ru (always up)                     -=/ SR 13 /=-


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19991119002759.B63288>