Search This Blog

Tuesday, January 24, 2012

Extracting file details from unix into peoplesoft

There are some cases where we would like to get the File details like timestamp etc from unix server into peoplesoft.

There are different approaches that we can follow to get file details from unix file server.

1. Use Shell script and write file attributes like owner,filename,lastupddttm etc to another file and then
    call this script from peoplecode Exec function.
2. User shell script and write file attributes to database record and then call this record from peoplecode.
3. Use Java language file class concept. Like instantiate the Java file object and then call the javamethod from   peoplecode to get the file attributes.

Let us see the first approach.

1. Use Shell script and write file attributes like owner,filename,lastupddttm etc to another file and then
    call this script from peoplecode Exec function.
 a) Create a shell script and execute from server to check the correctness of the script.
     pseudocode:
     Get the file details using ls -ltr command and store the output to variable
     Write these variables to a file.
b)  since we need file attributes of a particular file from a particular env, pass the filename and env as input.
c)  Use exec command from peoplecode and execute the script.
One challenge is in getting the file datetime values. In unix, ls -ltr will give file datetime till hours and mins but not secs.
Example: Abc.txt  Jan 14 5:29 but there are chances file might get overriden during the same time like 5:29 14 secs might get overriden at 5:29 42 secs. We cannnot find this using the ls -ltr command.  
To overcome this , use the perl script which will give the time till secs.

Thus we can get the file attributes from the above steps. Hope the info is useful.






No comments: