Shell programming - running the exe file and printing the output.. ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell programming - running the exe file and printing the output.. ?
# 8  
Old 01-25-2010
when i execute the shell script file dwarf_output.ksh as


Code:
ls  /logfile/lib  | while read filename
do
echo "STARTING THE FILE" $filename >>dwarf_output.txt
echo "*************************************">>dwarf_output.txt
dwarfdump $filename | grep DW_AT_SUN_command_line >>dwarf_output.txt
echo "END OF FILE " $filename >>dwarf_output.txt
done


the output file dwarf_output.txt contains dwarf_output.ksh also. telling

Code:
STARTING THE FILE dwarf_output.ksh
*************************************
END OF FILE  dwarf_output.ksh

i want to elimate the files starting with .ksh and .sql files.. how can i do this...?

kindly help
S

Last edited by zxmaus; 01-25-2010 at 03:17 AM.. Reason: added code tags
# 9  
Old 01-25-2010
I guess those are verbose messages.
In that case,
Code:
echo "verbose" > /dev/tty
echo "log message" > to_some_log_file

# 10  
Old 01-25-2010
it it not verbose

dwarf_output.ksh is the file where actual shell script is written. so when i execute

Code:
ls /logfile/lib | while read filename
do
echo "STARTING THE FILE" $filename >>dwarf_output.txt
echo "*************************************">>dwarf_output.txt
dwarfdump $filename | grep DW_AT_SUN_command_line >>dwarf_output.txt
echo "END OF FILE " $filename >>dwarf_output.txt
done

the scripts execute it's own file. ie
Code:
dwarfdump dwarf_output.ksh | grep DW_AT_SUN_command_line

so i dont want .ksh file to execute. how to elimate .ksh and .sql files

S

Last edited by zxmaus; 01-25-2010 at 03:18 AM.. Reason: added code tags
# 11  
Old 01-25-2010
First, its not a good idea to have bin files (scripts, executable, ..) in the same directory as in directory where data files are available.

Both of them should be abstracted in different directories.

Second,
probably you could check for existence of the literals, '.ksh' or '.sql' in the filename before processing them,
Code:
if required string literals are there 
then
  continue with the next file processing 
else 
  proceed with actual processing
fi

# 12  
Old 01-25-2010
hai

i have idea about filtering the files with find ./ -name "*.ksh" -print
but what is the command for listing all the files without .ksh and .sql files..?

can u pls tell the unix command for this..


waiting

S
# 13  
Old 01-25-2010
Quote:
Originally Posted by shenthil76
hai

i have idea about filtering the files with find ./ -name "*.ksh" -print
but what is the command for listing all the files without .ksh and .sql files..?

can u pls tell the unix command for this..


waiting

S
Try this:

Code:
find . -type f ! \( -name "*.txt" \) ! \( -name "*.sql" \)

Your version of find could differ from mine, if you get errors refer your local find command man page for more information.
# 14  
Old 01-25-2010
try this

if you are want your script not to execute itself, try
Code:
 
ls /logfile/lib | while read filename
do
if [ ! -f dwarf_output.ksh ]; then
echo "STARTING THE FILE" $filename >>dwarf_output.txt
echo "*************************************">>dwarf_output.txt
dwarfdump $filename | grep DW_AT_SUN_command_line >>dwarf_output.txt
echo "END OF FILE " $filename >>dwarf_output.txt
fi
done

or
Code:
 
ls /logfile/lib | while read filename
do
if [ ! -f $0 ]; then
echo "STARTING THE FILE" $filename >>dwarf_output.txt
echo "*************************************">>dwarf_output.txt
dwarfdump $filename | grep DW_AT_SUN_command_line >>dwarf_output.txt
echo "END OF FILE " $filename >>dwarf_output.txt
fi
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Printing Terminal Output to a Error File

I am having a bash script which is basically invoking a python program to validate the Source Query results against the target query results. I am placing all the queries in a .sql file. I want to write to a Error log file incase if the syntax is wrong or if the column is not present in the... (4 Replies)
Discussion started by: ronitreddy
4 Replies

2. UNIX for Dummies Questions & Answers

Help with printing advance output format from a file

Hi, below 'awk' code was given for my thread 'Help with printing output format from a file ' earlier, however script is not resulting expected output with below file content. cat test_tes123.dml record string("\001") emp_num; /* CHAR(11) NOT NULL*/ date("YYYYMMDD")... (1 Reply)
Discussion started by: AAHinka
1 Replies

3. UNIX for Dummies Questions & Answers

Help with printing output format from a file

Hi, I need help in printing data in below format from file extensions with .dml, i have listed details below file name is test_temp.dml, location in /home/users/test01/test_temp.dml file content: sample_type= record decimal(",") test_type; date("DD-MM-YYYY")(",") test_date... (2 Replies)
Discussion started by: AAHinka
2 Replies

4. Shell Programming and Scripting

Recursive file processing from a path and printing output in a file

Hi All, The script below read the path and searches for the directories/subdirectories and for the files. If files are found in the sub directories then read the content of the all files and put the content in csv(comma delimted) format and the call the write to xml function to write the std... (1 Reply)
Discussion started by: Optimus81
1 Replies

5. Shell Programming and Scripting

send arguments to a .exe file from a shell script

Folks , can anyone post a sample showing a way to parse a variable containing a string to a .exe file . Thanks Venu (2 Replies)
Discussion started by: venu
2 Replies

6. UNIX for Advanced & Expert Users

My command is still running but someone closed my shell, can I get my output still?

I ran an fs_usage (based off dtrace facility) but someone closed the window I think.. But I still see the process running # 15023 I tried fg 15023 but it told me no job control.. Is there anyway I can see my output? The scan has been running an hour and the output is valuable to me. (3 Replies)
Discussion started by: glev2005
3 Replies

7. Shell Programming and Scripting

output file of the shell script running through crontab is deleting automatical daily.

Dear Friends, I am working on IBM AIX. I have written one script and kept in the crontab as to run daily at 11:38 AM. and the output of the script to be appended to the file generated with the month name. but my file deleting daily and the new file is creating with the output of the shell... (2 Replies)
Discussion started by: innamuri.ravi
2 Replies

8. Programming

running exe

how we can run the exe when the system starts. (2 Replies)
Discussion started by: phani_sree
2 Replies

9. Programming

Running exe's from front end

Hi, I have created a tool which analyses and debugs cobol programs on Unix environment usin the C files. I now want to create a frontend for the tool in windows. For this i need to establish some kinda communication between the front the end and the back end. I know pipes in one way of... (0 Replies)
Discussion started by: Sinbad
0 Replies

10. UNIX for Dummies Questions & Answers

Running EXE files on UNIX

I'm trying to find out if a executible file created in visual basic will run in the CGI-BIN of a unix server. I see the C section but no mention of VB. Thanks Sean (1 Reply)
Discussion started by: seanstog
1 Replies
Login or Register to Ask a Question