Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk command exception in reading file

Status
Not open for further replies.

niet72

Programmer
Jul 17, 2008
7
0
0
US
Hi,

I have a script that has awk command( I am not a awk user), something like this:

awk '$0 != "" && $1 !~ /#/ {print $0}' "${FILENAMES}" | while read files
do
....
...
done

where ${FILENAMES} points to a file in the file system (filenames.txt) that has list of SQL script file names that needs to be deployed like this
@test1.sql
@test2.sql
@test3.sql

Now when the script runs the awk command fails with a fatal message:
awk: cmd. line:2: fatal: no (known) protocol supplied in special filename `/oracle/projects/Database/Deployment/filenames.txt'


Any ideas why this would be hapenning?

-Niet.
 
That's a strange one.

Can you add the following before that line and post the output:

Code:
ls -l "${FILENAMES}"
echo "${FILENAMES}" | cat -vet

Annihilannic.
 
Yes I already tried that. I get the file listing correctly with ls command and when I cat the file content using echo "${FILENAMES}" | cat -vet I get this:

/oracle/projects/Database/IDAA/Deployment/listfile.txt: line 1: @test1.sql: command not found
/inet/projects/Database/IDAA/Deployment/listfile.txt: line 2: @test2.sql: command not found
/inet/projects/Database/Deployment/filenames.txt: line 3: @test3.sql: command not found
 
Hmm... I'm none the wiser. That command should display the contents of the $FILENAMES variable, not the contents of the files themselves, and the output you gave doesn't look like cat -vet output (should have $'s on the ends of the lines).

What operating system are we looking at here?

Ah! I think I've got it... this must be GNU awk, which has some extensions for reading from remote hosts using a special filename syntax: /inet/<protocol>/<lport>/<rhost>/<rport>. By coincidence you are using filenames that match that prefix. You might have to rename the /inet directory to something else, or if that is difficult because of other dependencies, you could work around it by creating a symbolic link, e.g. ln -s /inet /inet_symlink and make the awk script read /inet_symlink/projects/Database/IDAA/Deployment/listfile.txt instead.

Annihilannic.
 
Actually, an easier workaround; just add the --traditional awk option which disables the GNU extensions.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top