If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Can't open the file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-26-10, 10:53
vineelaregonda vineelaregonda is offline
Registered User
 
Join Date: May 2009
Posts: 43
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.
Reply With Quote
  #2 (permalink)  
Old 02-26-10, 10:56
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Try:
Code:
TMPREPFILE=/home/xxx/yyv/tmp_rep_${day}.rpt
Mike
Reply With Quote
  #3 (permalink)  
Old 02-26-10, 11:51
vineelaregonda vineelaregonda is offline
Registered User
 
Join Date: May 2009
Posts: 43
Thanks for your immediate response.

Followed your suggsetion but still facing the same issue.
Reply With Quote
  #4 (permalink)  
Old 02-26-10, 12:22
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
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
Reply With Quote
  #5 (permalink)  
Old 02-26-10, 12:37
vineelaregonda vineelaregonda is offline
Registered User
 
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
Reply With Quote
  #6 (permalink)  
Old 02-26-10, 15:06
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
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.
Reply With Quote
  #7 (permalink)  
Old 02-26-10, 15:52
vineelaregonda vineelaregonda is offline
Registered User
 
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.
Reply With Quote
  #8 (permalink)  
Old 02-27-10, 03:43
AnanthaP AnanthaP is offline
Registered User
 
Join Date: May 2009
Location: India
Posts: 62
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
Reply With Quote
  #9 (permalink)  
Old 02-27-10, 03:49
AnanthaP AnanthaP is offline
Registered User
 
Join Date: May 2009
Location: India
Posts: 62
Can you substitute he ripple brackets with " so that he shell expands it correctly?

End
Reply With Quote
  #10 (permalink)  
Old 02-27-10, 07:58
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 626
Without the whole script, its difficult to determine the exact error.
It is possible that that TMPREPFILE has to be exported.

Quote:
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On