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.






Preserve case parameter in addattachment function

Below post is helpful to those who have encountered an issue with the file extension getting converted to lower case  instead of retain the same.

We use add_attachment(list_of_param....) to upload files to the server.
Inside the Add_attachment(list_of_param....) function there is a builtin library function addattachment(list_of_param....) which actually uploads the file in the server.

There is one parameter called preserve case which helps to retain the extension which user had uploaded.
By default, it is set to false.
That means if user uploaded "Test_File.TXT" , the file name on the server will be "Test_File.txt".

There could some cases where you feel the extension of the file should not change.
In that case , change the value to 'true'.

AddAttachment(URLDestination, DirAndFilename, FileType, UserFile[, MaxSize]                                                                     [, PreserveCase, UploadPageTitle])

Above syntax is from tools version 8.49