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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running awk script on a file in another folder

Status
Not open for further replies.

cgoodman

Programmer
Dec 29, 2008
7
Okay,

I am attempting to run a compiled awk executable against a file that is in another folder. I tried giving the executable the path of the file, but it gives an error, as if it cannot find the file.

Any ideas?

Thanks for all help.
 
Sorry, but what is a compiled awk executable ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
it is a windows executable that is created by compiling an awk script.

however, i'm not sure that that that is the essential point. I just want to run an awk script on a file that is located in a different folder. Is there anything I need to write to allow awk to handle this exception?
 
I tried giving the executable the path of the file
How did you that ?
In which shell ?
but it gives an error
What is the whole error message ?
Error raised by the shell or the compiled awk executable ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The error I was receiving was from the shell, and it was because I was creating a file inside the script which had a naming convention that began with the filepath. Therefore, because a filepath was inside name of the document that I am attempting to create, I was receiving an "file not found" error.

To go around this, I attempted to write code that extracted the name of the file that I wanted (just the filename, not any part of the path).

Code:
MYFILENAME = ARGV[1+(CR)+(FILEOPTION)+(GOODOPTION)+(DATA)];
split(MYFILENAME, filepath1, "\"");
split(filepath1, filepath2, "\\");

for(i=0;i<=length(filepath2);i++)
{
        if(filepath2[i] ~ ".txt$");
        {
                MYFILENAME = filepath2[i];
        }
}
split(MYFILENAME, pieces, ".");
 
You seriously have to read the awk documentation about the split function.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top