awk: can't open the file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk: can't open the file
# 1  
Old 07-19-2011
awk: can't open the file

I have a shell script with the following awk command.

Code:
awk '$1 == "GEOG_SRV"{split($2,a,":");print a[2]}' /etc/qm

when I run it manually command line its fine and giving the output.
Code:
bash-3.00$ awk '$1 == "GEOG_SRV"{split($2,a,":");print a[2]}' /etc/qm
9010

But in the script its throwing an error saying.


awk: can't open /etc/qm

Permissions seem to be fine.
Code:
ls -l /etc/qm
lrwxrwxrwx   1 root     root          11 Apr  6 09:23 /etc/qm -> /www/etc/qm
bash-3.00$ ls -l /www/etc/qm
-rwxr-xr-x   1 root     root        5389 Nov 29  2010 /www/etc/qm

Smilie

Please help me to find out the reason.
# 2  
Old 07-19-2011
Does a simple cat work on it or other files in /www/etc/qm. Are you root or another user which has no read permissions to /www/etc/qm or maybe missing execute to change directory?
# 3  
Old 07-19-2011
/www/etc/qm is a file and it has the enough permission. Im running the script as root and in the script it switches the user to "httpd"

I am running the awk command as a my own id..(not root/httpd)
# 4  
Old 07-19-2011
Dear Tuxidow,


try both the following in in command prompt , NOT in Shell

Code:
incommandprompt]# awk '{print }' /etc/qm

and

Code:
incommandprompt]# awk '$1 == "GEOG_SRV"{split($2,a,":");print a[2]}' /etc/qm

If it is working ,
it will be permission problem only
if it is not working,
it will be awk problem
# 5  
Old 07-19-2011
Thanks linux admin...both the awk commands are working from command prompt.. so as per you its permission issue? can you please help me in fixing it?
# 6  
Old 07-19-2011
yes. of course.

Give us your script.. Completely here.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk can't open file; file merge attempt

Dear all, I have an AWK related issue. I have two data files; the first, FileA has fewer lines, the second, FileB has more. FileA is a subset of FileB . Both files are tab delimited. What I want to do? When the first two columns for FileA match the first two columns of FileB, I want to... (4 Replies)
Discussion started by: A_Human_Person
4 Replies

2. Shell Programming and Scripting

awk (Too many open files)

Hi Team, This is my first post, hope I am doing it right. I have a large file, like 6 GB. Its a proxy file so vendor requested to change username from logs for saving the confidentiality of the user. This is the script I created (With the help of Google): awk '{ tmp="echo " $5 " |... (12 Replies)
Discussion started by: tealc
12 Replies

3. Shell Programming and Scripting

awk output yields error: awk:can't open job_name (Autosys)

Good evening, Im newbie at unix specially with awk From an scheduler program called Autosys i want to extract some data reading an inputfile that comprises jobs names, then formating the output to columns for example 1. This is the inputfile: $ more MapaRep.txt ds_extra_nikira_usuarios... (18 Replies)
Discussion started by: alexcol
18 Replies

4. Shell Programming and Scripting

Awk: can't open error

Hi , In a directory i've the files in the following format pay:year:mon:11789604 pay:year:mon:17675644 --- and i need to get 4th part of the above file name so i used awk command in the below code #!/bin/ksh for test_data in pay* do txt_awk = awk -F':' '{print $4;}' $test_data ... (7 Replies)
Discussion started by: smile689
7 Replies

5. Shell Programming and Scripting

Awk: can't open file!!

To whom it may concern, Please help! I am trying to use awk to open all the files in a folder and remove one row and append everything into an output file. for X in `ls /Users/misssmith/Desktop/birdseed/`; do awk '(NR==546412)' /Users/misssmith/Desktop/birdseed/$X >>... (6 Replies)
Discussion started by: salpie
6 Replies

6. Shell Programming and Scripting

Awk: cannot open file (No such file or directory)

Hello folks! I am new to Shell and awk scripting. This is my shell script that receives a string as an input from the user from the stdin. #!bin/sh printf "Enter your query\n" read query cmd=`echo $query | cut -f 1 -d " "` input_file=`echo $query | cut -f 2 -d " "` printf $input_file... (10 Replies)
Discussion started by: radiohead_
10 Replies

7. 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

8. Shell Programming and Scripting

awk Can't open file

Hello all, I am creating a small bash script to cycle through some files that are the results of an analysis I have run (I am a statistician). There are many folders called job001, job002,...,job135. Each folder has a text file called results.txt. I want to create two summary files of the... (3 Replies)
Discussion started by: jem43
3 Replies

9. Shell Programming and Scripting

awk: can't open

Hi Guys, I was just trying to run a bunch of test scripts which ran perfectly before i changed servers to a different solaris machine. But i just changed it to run on a different solaris version and my awk statement in the script shows an error. awk BEGIN{s=ARGV; r=ARGV; \ ... (2 Replies)
Discussion started by: wick3dsunny
2 Replies

10. Shell Programming and Scripting

awk: cannot open inputf

I'd like some help with awk too. Somewhere in my bash script i have written something like this: awk -v outputfile=$finalFile -v inputf=$file 'BEGIN { commands } { more commands } ΕND{ }' inputf where the file is a .input file with data. I also tried this: awk -v... (2 Replies)
Discussion started by: little_fairy
2 Replies
Login or Register to Ask a Question