Can ls in ksh write to output?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can ls in ksh write to output?
# 1  
Old 01-27-2009
Can ls in ksh write to output?

I have a ksh script written by someone... now i am trying to modify it to my requirement....

Its executed like this

Read.ksh load ${CUR_MAINT_DATE}

Code:
 
if [ "${1}" = "" ]
then
 filnam="Load_CLM"
else
 filnam="${1}"
fi
if [ ! "${2}" = "" ]
then
 CUR_MAINT_DATE="${2}"
fi
if [ -f ${LOG_DIR}/${CUR_MAINT_DATE}/${filnam}_200*log ]
then
  ls ${LOG_DIR}/${CUR_MAINT_DATE}/${filnam}_200*log
  grep 'STEP 00' ${LOG_DIR}/${CUR_MAINT_DATE}/${filnam}_200*log > r.tmp
  date1=`tail -1 r.tmp | cut -f2 -d '[' | cut -f1 -d ']'`
  grep 'Completed at \[' ${LOG_DIR}/${CUR_MAINT_DATE}/${filnam}_200*log > r.tmp
  date2=`tail -1 r.tmp | cut -f2 -d '[' | cut -f1 -d ']'`
  rm -f r.tmp

This code actually writes to a file... when i see in the file i see the value of {LOG_DIR}/${CUR_MAINT_DATE}/${filnam}_200*log
its the location of the log file... now we dont want it and i am not able to figure out what is giving that output...
After putting some echo statements i found that its thai statement thats writing
Code:
 
ls ${LOG_DIR}/${CUR_MAINT_DATE}/${filnam}_200*log

I kept echo after every line to see which line is writing... Can anyone say me what i have to do so that it doesnt write the value of ${LOG_DIR}/${CUR_MAINT_DATE}/${filnam}_200*log to output...

Thanks a lot
# 2  
Old 01-27-2009
Thanks a lot for being there for me... I got the solution... i just removes the ls...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Changes to write output to logfile and console

Friends, Below is the script which writes output to LOGFILE, however I want the entire log written to LOGFILE and also console. Please suggest me the changes I need to do here. #!/bin/ksh x=${0##*/} LOGFILE="x.log" echo "CAUTION : Files once deleted cannot be restored" printf 'Would... (8 Replies)
Discussion started by: fop4658
8 Replies

2. Shell Programming and Scripting

Write result to output file

Good morning everybody, Beeing an absolute newbie in shell scripting I would like to look for some help here. I would like to read an external text file and format the data and write it to an output file. What I was trying to do was to display the result (this worked). But now I... (1 Reply)
Discussion started by: bluejean1976
1 Replies

3. Shell Programming and Scripting

Filter out output and then write to a file

I have a process which writes lots of output to the screen and am capturing it to a file. But the issue is that there are few lines which repeat every second which is causing the file size to be enormous. I am trying to filter out and then run the command but its not working. Can you confirm... (7 Replies)
Discussion started by: rajkumarme_1
7 Replies

4. Shell Programming and Scripting

KSH - need to write a script to abbreviate a string

Dear Members, I have to write a UNIX script (KSH) to create a 6 letter abbreviation from a given string. The string will have alphabets and underscores only. e.g. abc_pst_xyz is our string and I have to create an abbreviation which will look like 'abpsxy' or 'abcpyz' etc. Now comes the... (8 Replies)
Discussion started by: Yoodit
8 Replies

5. Red Hat

write execl output to file

hi, how to write the resullt of execl() into another file. i used write(fd,execl()); (1 Reply)
Discussion started by: Mahendravarma
1 Replies

6. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

7. Shell Programming and Scripting

output to write in a file

hi all, when i try to start an applicationserver for an example: ./kStart.sh > out.txt so kStart.sh script will start the application server and write the details to out.txt but in mycase... it is writing to out.txt and as well it is showing in the prompt also... I want only the... (2 Replies)
Discussion started by: raghur77
2 Replies

8. Shell Programming and Scripting

How do I write a ksh script that will check if all ftp files are received?

I am trying to code a ksh script that will check to see if all 26 incoming ftp files have been received before proceeding to the next function, which is to rename each file. Here is the pseudo-code of what I am trying to do: <<STEP_1>> IF all ALS files have been transmitted then... (2 Replies)
Discussion started by: doug145
2 Replies

9. Shell Programming and Scripting

Write process output to a file

When I run <ls -l> to get a list of all the files, I want the displayed result to be written to a text file. Is there a way to do that? (1 Reply)
Discussion started by: kn.naresh
1 Replies

10. Shell Programming and Scripting

How to write a varible into file in ksh

set filename $logDir/PyLog/$logname echo $filename >> logname.txt I am trying to write to write the varibale filename into a file logname.txt,it is not working could any one suggest y (2 Replies)
Discussion started by: nathgopi214
2 Replies
Login or Register to Ask a Question