Results 1 to 10 of 10
  1. #1
    Join Date
    May 2009
    Posts
    43

    Unanswered: Can't open the file

    At declaration part of the script, I have declared the reporting file as follows:

    TMPREPFILE=/home/xxx/yyv/tmp_rep_{$day}.rpt


    In side the script I am trying to open $TMPREPFILE.1

    I am getting the msg can't open tmp_rep_{$day}.rpt.1

    Can you please help how to overcome this error msg and why it's not working.

    Thanks in advance.

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Try:
    Code:
    TMPREPFILE=/home/xxx/yyv/tmp_rep_${day}.rpt
    Mike

  3. #3
    Join Date
    May 2009
    Posts
    43
    Thanks for your immediate response.

    Followed your suggsetion but still facing the same issue.

  4. #4
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    I just quickly fixed what appeared to be an error.

    What is the name of the file you are trying to open?
    What does the variable $day contain?
    What does the variable $TMPREPFILE contain?

    Mike

  5. #5
    Join Date
    May 2009
    Posts
    43
    The file I am trying to open is $TMPREPFILE.1

    My declaration for the $TMPREPFILE is as follows:

    TMPRPTFILE=/home/aaaa/sec_scb_sby_32_39_40_${day}_${time}.rpt


    Content of the $TMPRPTFILE looks like :


    SEC_BSC_SBY_037,host,er2lpgsr1,master,f351240,f353 871
    SEC_BSC_SBY_037,host,e2lpgsr1,master,f353871,f2537 60
    SEC_BSC_SBY_037,host,ge2lpgsr1,master,c23622,f3546 27
    SEC_BSC_SBY_037,host,qe2lpgsr1,master,f351240,f353 871
    SEC_BSC_SBY_037,host,ve2lpgsr1,master,f353871,f253 76

    Let me know if you need any more information.

    Thanks

  6. #6
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Quote Originally Posted by vineelaregonda View Post
    The file I am trying to open is $TMPREPFILE.1

    My declaration for the $TMPREPFILE is as follows:

    TMPRPTFILE=/home/aaaa/sec_scb_sby_32_39_40_${day}_${time}.rpt
    I'm not sure what the name of the file is from the above. If it's whatever is in the TMPREPFILE variable with ".1" added to the end then use :
    Code:
    ${TMPREPFILE}.1
    If you don't show what the variable $TMPREPFILE contains then we won't know if the variables day and time are set correctly. It is best to just do one small thing at a time when changing unix shell scripts and, if anything doesn't work, to just echo out the values of all the variables concerned.

  7. #7
    Join Date
    May 2009
    Posts
    43
    Thanks for your reply.

    I followed your suggestion and also removed the date and time variable from the file name but still getting the same error.

    But as you mentioned, i just created one file and passing the output to test.log and at then end I did

    cat test.log >> test.log.1

    This is working perfect. But I don't know why the same is not working in side the script.

  8. #8
    Join Date
    May 2009
    Location
    India
    Posts
    66
    Basically the value of $day and $time are not expanding on the fly - as we expect they should in a shell.

    So the first thing that you check is he environment where you make the assignment to TEMPREP... If this is all right, then next I would try `echo $day` (enclosed in back-quotes / back ticks) to make the variable.

    End

  9. #9
    Join Date
    May 2009
    Location
    India
    Posts
    66
    Can you substitute he ripple brackets with " so that he shell expands it correctly?

    End

  10. #10
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Without the whole script, its difficult to determine the exact error.
    It is possible that that TMPREPFILE has to be exported.

    I am getting the msg can't open tmp_rep_{$day}.rpt.1
    If this is the exact error message, then $TMPREPFILE is either re-defined, or non existent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •