Output file ownership
Tom
tla at aldridgeinc.com
Thu May 18 23:05:42 PDT 2006
> From: Tom <tla at aldridgeinc.com>
> Subject: Output file ownership
>
> In searching my archives I find discussions about permissions but not
> ownership.
>
> Scenario:
>
> From input processing I create the first file below.
>
> system "echo \"<PRE>\" > /appl/fpmerge/html/" {jobname {".html"
>
> Which results in the file being owned by the user (in this case 14):
>
> -rw------- 1 14 stores 13 May 18 10:13 we052806.html
>
> Then I run rreport, which results in the file below that is owned by
> filepro.
>
> rptstring="/appl/fp/rreport scheddet -f sched -v schedsel -a -ia -u -r"
> <1 <"-rw" <4 <"-rx" <5
> rptstring=rptstring <"-h" <"\"" <jobname <"\"" <"-pn nocodes -p
> /appl/fpmerge/html/ " {jobname
>
> -rw------- 1 filepro stores 4540 May 18 10:13 we052806
>
> Now I cat the output file to the first file and append a tag:
>
> system "cat /appl/fpmerge/html/ " {jobname <">>" <"/appl/fpmerge/html/"
> {jobname {".html"
> system "echo \"</PRE>\"" <">> /appl/fpmerge/html/" {jobname {".html"
>
> Finally I ftp the file to different server:
>
> THE PROBLEM is it won't allow the cat of the rreport output file to the
> first file because the ouput file is owned by filepro and the other by
> the user. What should I do here? Thanks in advance.
>
> Tom Aldridge
>
>
> ------------------------------
>
> Message: 5
> Date: Thu, 18 May 2006 12:43:05 -0400
> From: Fairlight <fairlite at fairlite.com>
> Subject: Re: Output file ownership
> To: filePro Mailing List <filepro-list at lists.celestial.com>
> Message-ID: <20060518124305.A17448 at iglou.com>
> Content-Type: text/plain; charset=us-ascii
>
> Yo, homey, in case you don' be listenin', Tom done said:
>
>>In searching my archives I find discussions about permissions but not
>>ownership.
>>
>>Scenario:
>>
>> From input processing I create the first file below.
>>
>>system "echo \"<PRE>\" > /appl/fpmerge/html/" {jobname {".html"
>>
>>Which results in the file being owned by the user (in this case 14):
>>
>>-rw------- 1 14 stores 13 May 18 10:13 we052806.html
>>
>>Then I run rreport, which results in the file below that is owned by
>>filepro.
>>
>>rptstring="/appl/fp/rreport scheddet -f sched -v schedsel -a -ia -u -r"
>><1 <"-rw" <4 <"-rx" <5
>>rptstring=rptstring <"-h" <"\"" <jobname <"\"" <"-pn nocodes -p
>>/appl/fpmerge/html/ " {jobname
>>
>>-rw------- 1 filepro stores 4540 May 18 10:13 we052806
>>
>>Now I cat the output file to the first file and append a tag:
>>
>>system "cat /appl/fpmerge/html/ " {jobname <">>" <"/appl/fpmerge/html/"
>>{jobname {".html"
>>system "echo \"</PRE>\"" <">> /appl/fpmerge/html/" {jobname {".html"
>>
>>Finally I ftp the file to different server:
>>
>>THE PROBLEM is it won't allow the cat of the rreport output file to the
>>first file because the ouput file is owned by filepro and the other by
>>the user. What should I do here? Thanks in advance.
>
>
> Obviously a linux system with a bash shell v2.0 or higher...
>
> The problem is that bash drops EUID unless told not to with a command line
> flag, and that option isn't available via the system() command.
>
> Personally, I'd dump the system echo statements and take the tiny time to
> learn open(), readline(), writeline(), and close(). You can do the entire
> thing in filePro, and the filepro user will own the entire file the whole
> way through.
>
> Your other option is to use sudo to be able to call certain commands as
> filepro. Namely, you could explicitly allow /bin/echo and /bin/cat to be
> executed as filepro via the sudo configuration, and prepend 'sudo' to your
> commands that aren't rreport. Not a solution I'd recommend, although it
> would work.
>
> It's more sensible (and less open to abuse, and less of a PITA to maintain
> when new users come around and need adding to the ruleset) to just do it
> all inline with raw I/O commands.
>
> Copying a file inside fP takes very few lines of code. Declare a few
> variables on one, two opens on a line, two closes on a line, say two lines
> of sanity error checking that most people except me manage to skip, and
> 1-2 lines of looped read/write between them depending how you write it.
> Trivial, and it solves the problem. About six lines or so if done very
> compactly. A few more if you like to break it down for utter clarity of
> form. Same goes for just writing to the file initially and after the fact.
> Have to watch whether you want that open() to append or not for head or
> mid/tail, but other than that one character difference in open() flags,
> it's open(), as many writeline()'s as you need to get the job done, and a
> close().
>
> mark->
>
>
Mark. Thanks for the help. I reworked the code as follows. Not sure if
it's anything like you would have done but here it is and then another
question at the end
html:::
::declare rptstring, handle(8,.0), jobname(8,*)
::jobname="we"{doedit(4,"mdy","6"):
:jobname co chr("32") 'eliminate any space in job name
:jobname=xlate(jobname,chr("32"),""):
::rptstring="/appl/fp/rreport scheddet -f sched -v schedsel -a -ia -u
-r" <1 <"-rw" <4 <"-rx" <5:
::rptstring=rptstring <"-h" <"\"" <jobname <"\"" <"-pn nocodes -p
/appl/fpmerge/html/ " {jobname&".html":
::system rptstring:
::handle=OPEN("/appl/fpmerge/html/"&jobname&".html","rwt"):
:handle le "0" 'Open failed.
:end:
::x = WRITELINE(handle,"<PRE>"):
::x = seek(handle,"0","e") 'position to end of file:
::x = WRITELINE(handle,"</PRE>"):
::system "ftp -in </usr/apps/fpftpsched"&1:
::x = REMOVE("/appl/fpmerge/html/"{jobname&".html"):
Appearing below are the first few lines of the resultant file. The issue
is that it's cutting off the first three characters (should be SCHEDULE,
not EDULE). Any direction on that issue? Thanks again.
<PRE>
EDULE -- W/E 05/28/2006 Store No. 14 Printed 05/19/06 00:51 Rev. 5
+----------------+-----+-------+-------+-------+-------+-------+-------+-------+|
NAME |SHIFT| MON | TUE | WED | THU | FRI | SAT |
SUN
|+----------------+-----+-------+-------+-------+-------+-------+-------+-------+|
RONDA D | | Leave | Leave | Leave | Leave | Leave | Leave |
Leave
|+----------------+-----+-------+-------+-------+-------+-------+-------+-------+
Tom
More information about the Filepro-list
mailing list