Is there a diff way to exec this shell prg??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Is there a diff way to exec this shell prg??
# 1  
Old 06-27-2007
Is there a diff way to exec this shell prg??

Hi,

I want to know whether it is possible to to execute the below script like

ksh ds.ksh <input file> > <output file> or any other simple way other then ./

The way i'm executing it right now is

nawk -f ds.ksh <input file> > <output file>.

I need the first format as my ETL tools is not able to understand the nawk -f execution format.Is there any change within the program i need to do ?


#!/usr/bin/nawk -f

BEGIN {
FS=OFS="|"

FLD_max=11

FF=sprintf("\f")

}
$0 ~ FF { gsub(FF, ""); $1=$1 }

(fld + NF-1) > FLD_max {
if (fld == FLD_max)
print rec

}
##NF < FLD_max {printf("Bad record: [%d] :: [%s]\n", FNR, $0) | stderr;
NF < FLD_max {rec=(rec != "") ? rec $0 : $0; fld+=(NF-1);next }
{rec=$0; fld=NF}
END {
if (rec != "" && split(rec, a, FS) >= FLD_max ) print rec

Regards,
Kumar
# 2  
Old 06-27-2007
Rename your file from ds.ksh to ds.awk (optional but recomended)
Make executable your awk script file.
Run your script file.

Code:
$ mv dt.ksh dt.awk
$ chmod +rx dt.awk
$ dt.awk infile > outfile

# 3  
Old 06-27-2007
Quote:
Originally Posted by aigles
Rename your file from ds.ksh to ds.awk (optional but recomended)
Make executable your awk script file.
Run your script file.

Code:
$ mv dt.ksh dt.awk
$ chmod +rx dt.awk
$ dt.awk infile > outfile


HI Aigles,

Thats the way i was executiong before on the shell prompt.But now i want to call this within the ETL tool.The ETL tool which is use understand the scripts when it is executed like this

ksh or sh <path of script> > <path of log> 2>&1

I want to know whether it is possible to execute the script in the above manner instead of pointing the interpreter to nawk -f execution.

Regards,
Kumar.
# 4  
Old 06-27-2007
Code:
ksh -c 'nawk -f dt.ksh infile > outfile'

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Simple shell running with exec family

# Erroneous question, so can be removed. (0 Replies)
Discussion started by: beginnerboy
0 Replies

2. UNIX for Beginners Questions & Answers

Two exec commands in one shell script?

Hi Folks - Is there a way to add two execs to one script? For instance, I need to redirect the stdout and stderr to two separate directories. I want to do this: #::-- Direct STDOUT and STDERROR to repositories --::# exec 2>"${_ERRORFILE}" > "${_LOGFILE}" exec 2>"/new/path/file.err" >... (7 Replies)
Discussion started by: SIMMS7400
7 Replies

3. Shell Programming and Scripting

What does the following exec command do it is in the shell file?

I have a shell script, research_dump_sub.sh the first 3 lines are below. the below two lines writing to log file, i am not finding the log file, how to locate, and what is the exec command doing exactly please. and the third line again calling/triggering the shell file. i didn't understood. ... (2 Replies)
Discussion started by: cplusplus1
2 Replies

4. Shell Programming and Scripting

Exec shell from Ant target

hi, I have been using exec in Ant to run shell commands till now, but got a weird error now. I have an ANT target which invokes a shell script. Shell script further invokes one more shell script file to complete the work. Below is Ant Target code. <exec executable="/bin/bash"> ... (2 Replies)
Discussion started by: sukhdip
2 Replies

5. Shell Programming and Scripting

Script Variables Inquiry, Values Okay in Standalone Exec, No-Show in Cron Exec

I have the following bash script lines in a file named test.sh. #!/bin/bash # # Write Date to cron.log # echo "Begin SSI Load $(date +%d%b%y_%T)" # # Get the latest rates file for processing. # d=$(ls -tr /rms/data/ssi | grep -v "processed" | tail -n 1) filename=$d export filename... (3 Replies)
Discussion started by: ginowms
3 Replies

6. Shell Programming and Scripting

serach diff filename in diff location using shell scripting

Hi, I am new to shell scripting. please help me to find out the solution. I need a script where we need to read the text file(consists of all file names) and get the file names one by one and append the date suffix for each file name as 'yyyymmdd' . Then search each file if exists... (1 Reply)
Discussion started by: Lucky123
1 Replies

7. Shell Programming and Scripting

how to use exec command in C shell

i have a script where i am reading some lines from a file into another file.. script works fine in bash.. #!/usr/bin/csh awk 'NR>20&&NR<32' try.sum | awk '{print $4 }' >io awk 'NR>20&&NR<32' try.sum | awk '{print $9 }' >io1 awk 'NR>20&&NR<32' try.sum | awk '{print $14 }'>io2 exec 10<io... (1 Reply)
Discussion started by: npatwardhan
1 Replies

8. Shell Programming and Scripting

Exec bash shell via PHP Site !

Hi everybody ! I writed php code so exec bash shell via php (SMS Send via bash shell) but i have problem as follow : 1. When i exec from linux mode : ./sms.sh --- output is "Messages ... OK". Then all message has been sent. 2. When i exec from PHP site --- return value is "Message ... OK" on... (1 Reply)
Discussion started by: lamthenhan
1 Replies

9. Shell Programming and Scripting

calling a prg from the shell!!!

Hi, can somebody please answer my questions: 1) is the "sh" available on all unix systems at /bin/sh ??? 2) how to make the following call working: `which java` -cp $JAVA_HOME MyClass since I do not know the location of java :-(( (4 Replies)
Discussion started by: andy2000
4 Replies
Login or Register to Ask a Question