ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

IFS Object not found error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • IFS Object not found error

    Hi All

    Hope all are staying safe!!!

    I have a requirement to create a text file in IFS and write log data into it.

    I used SCOTT's IFSIO and IFSTEXT code to do this. To open the file, I used the below command.

    Code:
    unlink(AucFileName) ;                                 
    aucfd = open(AucFileName:                             
              O_RDWR + O_CREAT + O_TEXTDATA :             
              S_IRUSR + S_IWUSR + S_IXUSR +               
              S_IRGRP + S_IWGRP + S_IXGRP +               
              S_IROTH + S_IWOTH + S_IXOTH);
    With this, I was successfully able to create the file and I used write() function to add content into the txt file.

    Code:
    linelen = %len(%trimr(line));         
    writeLine(aucfd:%addr(Line):linelen);
    My file looks something like this in the IFS.

    To view, the below text file, I had to do WRKLNK '/home/user', press ENTER, scroll down till I find TMP20200531.TXT and press 5 to open the file.
    PHP Code:
     Browse : /home/user/TMP20200531.TXT                                                   
     Record 
    :       1   of      92 by  18                      Column :    1    200 by 131     
     Control 
    :                                                                                 

    ....+...
    .1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9.
     ************
    Beginning of data**************                                               
    Test Log for the servers
    Date
    05/31/20     Time18.40.22                                                          
    -------- Auction IBMi -------                                                              
    SUCCESS Ping Result for Server1
    SUCCESS 
    Ping Result for Server2                                                            
    SUCCESS 
    Ping Result for Server3                                                          
    FAILURE 
    Ping Result for Server4                                                         
    SUCCESS 
    Ping Result for Server5                                                          
    SUMMARY 
    4/5 server responses are SUCCESS 
    Even though, I was able to write successfully into the IFS text file, I could not access the file directly using WRKLNK command.

    When I used WRKLNK on the /home/user/TMP20200531.TXT. I am getting Object not found error.

    I wanted to use this file as an attachment in SNDSMTPEMM command to send it via email. I am getting the below error.

    PHP Code:
    Integrated File System File Not Found
    After giving all access to the file using the MODE flags, I am not sure like what to do. Can anyone please suggest me a solution for my issue?

  • #2
    Best guess is that you have spaces at the end of your file name. i.e. it is ...TXTbbbb...bbb

    I don';t have the protos for Scott's routines handy but check how they are defined and what you are passing. Check if AucFileName is a Varchar and if so if you used %TrimR to load it. If it is a fixed char field then use %Trim on the call to open().

    Comment


    • #3
      Originally posted by JonBoy View Post
      Best guess is that you have spaces at the end of your file name. i.e. it is ...TXTbbbb...bbb

      I don';t have the protos for Scott's routines handy but check how they are defined and what you are passing. Check if AucFileName is a Varchar and if so if you used %TrimR to load it. If it is a fixed char field then use %Trim on the call to open().
      Excellent.. Thats the issue.. Now it worked perfect.. Thank you very much for your quick response!!!!

      Comment


      • JonBoy
        JonBoy commented
        Editing a comment
        Glad it worked out for you.

    • #4
      The first parameter of the open() prototype is a good place to use OPTIONS(*STRING:*TRIM).

      Comment

      Working...
      X