cat can not open file


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users cat can not open file
# 1  
Old 05-09-2011
cat can not open file

Hi All,

I have stumbled upon very unique issue. In my script I am doing cat file and then greping and cutting so as to assign the value to variable. My file is,

<mxc_tl_load_extractdata_prop.bsh>

Code:
DB_USER=test_oper hostname=xxx FTP_USER=test1_operate
MAIL_LIST=xxx@yyy.com SLEEPTIME=7200 PROD_CONN=aaa.bb.cc.com UAT_CONN=bbb.bb.cc.com PROD_FTP_HOST=x1.bb.cc.com UAT_FTP_HOST=y1.bb.cc.com



In my script ,
Code:
FTP_USER=`cat mxc_tl_load_extractdata_prop.bsh| grep -i "FTP_USER"|cut -d"=" -f2`



This command did not work and gives error as
cat: cannot open mxc_tl_load_extractdata_prop.bsh

But in the same script after above command next variable "hostname" is able to be extracted (with exact same command) and is assigned to variable.

The script worked on "SunOS 5.8 Generic_117350-55 sun4us sparc FJSV,GPUZC-Land" but issue is coming on "SunOS 5.10 Generic_137111-04 sun4u sparc SUNW,SPARC-Enterprise"

I have alrady checked for white space issue.

Can anybody help? Smilie

Regards
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 05-09-2011 at 08:50 AM.. Reason: code tags, please!
# 2  
Old 05-09-2011
First check both scripts for invisible bad characters. This sed command is designed to make control characters visible.
Code:
sed -n l scriptname


Aside. A better method is to "source" the variables.
e.g. In the main script use the construct dot-space-filename to invoke the other script in your environment. This single command line will set all the environment variables in one go.
Code:
. ./mxc_tl_load_extractdata_prop.bsh

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ssh cat file output into a file on local computer

Hello, I'm on a remote computer by SSH. How can I get the output of "cat file" into a file on the local computer? I cannot use scp, because it's blocked. something like: ssh root@remote_maschine "cat /file" > /locale_machine/file :rolleyes: (2 Replies)
Discussion started by: borsti007
2 Replies

2. Shell Programming and Scripting

Cannot open txt file in UNIX using cat utility

Hi, I am not being able to open txt files with 'cat'. One thing to mention is, the filenames start with #. I guess one can have a unix filename that starts with a special/wildcard character. I have filenames starting with @ and they are opening perfectly with cat. (5 Replies)
Discussion started by: Subhasis
5 Replies

3. Shell Programming and Scripting

Error : cat: 0652-050 Cannot open

After processing around 300 files , I am getting the below error.Please help me to resolve it cat: 0652-050 Cannot open /dir1/dir2/dir3/dir/abc.txt mv: 0653-401 Cannot rename /dir1/dir2/dir3/dir/abc.temp to /dir1/dir2/dir3/dir/abc.csv: . . . how to avoid it. because I am getting... (1 Reply)
Discussion started by: vsachan
1 Replies

4. UNIX for Advanced & Expert Users

for i in `cat file` do

in bash: for i in `cat file` ; do echo $i done; how will i do this in perl ? (10 Replies)
Discussion started by: linuxgeek
10 Replies

5. Red Hat

cannot set user id: Resource temporarily unavailable (not open file/open process related)

First post, sorry to be a bother but this one has been dogging me. I have a process user (java application server) that trips a resource limit every couple weeks and need help finding what limit we're hitting. First, this is what's running: This is the error when jobs are run or the... (0 Replies)
Discussion started by: Katahdin
0 Replies

6. Shell Programming and Scripting

Read files, lines into array, cat vs open

Hi Everyone, I have a file: a.txt a,b,c,d,6,6,6 1,2,3,d,6,6,6 4,5,6,6,6,6,6 #!/usr/bin/perl use warnings; use strict; my @array = (); ### Load file into array for my $i (split '\n', `cat /tmp/a.txt`) { push @array, ; } It works. But my a.txt have 1million lines, and... (2 Replies)
Discussion started by: jimmy_y
2 Replies

7. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

8. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies

9. UNIX for Dummies Questions & Answers

Easiest way to cat out first 100 lines of a file into a different file?

Not sure how to do this exactly.. just want to take the first 100 lines of a file and cat it out into a second file. I know I can do a more on a file and > it into a different file, but how can I make it so only the first 100 lines get moved over? (1 Reply)
Discussion started by: LordJezo
1 Replies
Login or Register to Ask a Question