Urgent!!!Read directory from a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Urgent!!!Read directory from a file
# 1  
Old 05-11-2007
Question Urgent!!!Read directory from a file

I have a receive script file which had lots of direcorties to process,but now,I don't want to hardcode them,I need input the directory name in a Property.txt file,then write shell code to read the directory name from Property.txt to the script file so I can get flexible on it.But when I ran the sh file it met error.

Property.txt
Code:
New_receive_directory_is=/home/joshua/bodi/data/receive
New_temp_directory_is=/home/joshua/bodi/data/temp
New_working_directory_is=/home/joshua/bodi/data/working
New_archive_directory_is=/home/joshua/bodi/data/archive

receive.sh
Code:
#!/usr/bin/ksh
GlobalValueReceive=r
GlobalValueWorking=w
GlobalValueTemp=t

$exec 0<Property
while read LineInProperty
do
  if [ ${LineInProperty:0:11} = New_receive ]
  then
     $GlobalValueReceive = ${LineInProperty:25} 
  fi
  if [ ${LineInProperty:0:11} = New_working ]
  then
     $GlobalValueWorking = ${LineInProperty:25}
  fi
  if [ ${LineInProperty:0:8} = New_temp ]
  then
     $GlobalValueTemp = ${LineInProperty:22}
  fi
done

(($#<2)) && { print "2 parameters: \n    p_seq_no\n    p_sys_ind"; exit 1; }

typeset -i pass_check
typeset -i p_seq_id

p_seq_id=$1
p_sys_ind=$2
pass_check=0

# file's count
check_count=`ls -l ${GlobalValueReceive}/${p_sys_ind}.Witness*|grep "^-"|wc -l`

print ${check_count} seq files

for i in $(ls ${GlobalValueReceive}/${p_sys_ind}.Witness*)
do
  seq_id=${i##*Witness.}
  seq_id=${seq_id%%.*}
  mv ${GlobalValueReceive}/${p_sys_ind}.*.${seq_id}.* ${GlobalValueTemp}/dos/
done

for i in $(ls ${GlobalValueTemp}/dos/*)
do
  #dos2ux ${i} > ${GlobalValueTemp}/dos2/${i##${GlobalValueTemp}/dos/}
cat ${i} > ${GlobalValueTemp}/dos2/${i##${GlobalValueTemp}/dos/}
cat ${GlobalValueTemp}/dos2/${i##${GlobalValueTemp}/dos/} | tr -d "
" > ${GlobalValueTemp}/${i##${GlobalValueTemp}/dos/}   
  rm ${i}
done

print files have been moved to temp folder

for i in $(ls ${GlobalValueTemp}/${p_sys_ind}.Witness*)
do
  print begin to check the files with seq_id ${p_seq_id}
  if [ ${p_sys_ind} = 111111 ]
  then
    /home/bodi/bin/ef_validate.sh ${p_seq_id}
  else
    /home/bodi/bin/mp_validate.sh ${p_seq_id}  
  fi
  
  return_code=$?
  if [ ${return_code} = 0 ]
  then
    print file with seq_id ${p_seq_id} passed!
    mv ${GlobalValueTemp}/${p_sys_ind}.*.${p_seq_id}.* $GlobalValueWorking/
    mv $GlobalValueWorking/${p_sys_ind}.Witness.${p_seq_id}.*.txt $GlobalValueWorking/${p_sys_ind}.Witness.${p_seq_id}.txt 
    pass_check=${pass_check}+1
    p_seq_id=${p_seq_id}+1
  else
    print file with seq_id ${p_seq_id} failed!
    for j in $(ls ${GlobalValueTemp}/${p_sys_ind}.*.${p_seq_id}.*)
    do
      mv ${j} ${GlobalValueWorking}/${return_code}.${j##${GlobalValueTemp}/}.rej
    done
    for j in $(ls ${GlobalValueTemp}/${p_sys_ind}.*)
    do
      mv ${j} ${GlobalValueWorking}/1.${j##${GlobalValueTemp}/}.rej
    done
    break
  fi
done

print quit with ${pass_check} passed check  
exit ${pass_check}

This problem is very urgent,thank you for your assistance.
# 2  
Old 05-11-2007
PHP

Duplicated thread
# 3  
Old 05-11-2007
Quote:
Originally Posted by aigles
Duplicated thread
Hello,

I didn't have any shell programming experience before,I was a Java programmer.So I need you guide to help this code can read directory string from a file.

Regards,
Joshua
# 4  
Old 05-11-2007
What exactly is the problem? You have a script there, is there something that is wrong with it? I don't want to have to read through the whole thing checking it for you.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash shellscriptname.sh input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies

2. Shell Programming and Scripting

read file by file in a directory

Hi I have directory which has 5 files names test1, test2, test3, test4, test5 Now i want to read file by file and generate md5checksum. Command used is md5sum test1. How can i read file names one after the other and generate checksum and send the output to a file. Please reply (3 Replies)
Discussion started by: vasuarjula
3 Replies

3. Shell Programming and Scripting

How to read file names in the directory?

I am having n files in a directory i want to read all the file names from the script file .It is better if any one provide a sample script. Elaborating the scenario: i am having n number of sql files in a directory i am running all the sql files from a single script. sqlplus... (4 Replies)
Discussion started by: dineshmurs
4 Replies

4. Shell Programming and Scripting

To copy a a file to last created directory..Urgent pls

I need to copy a file example hhh.txt to the recently created directory by name flexite@latesttimestamp in the path interface/home/ ... I couldnt get the name of recently created directory .... first result of ls -lst ...that is ls -lst |head -2 gives the latest directory but i could not... (2 Replies)
Discussion started by: helloo
2 Replies

5. Shell Programming and Scripting

URGENT : vi doesn't read my .exrc

I have created some custom commands (using the map macro feature) and have those map commands in my $HOME/.exrc file (I am using bash) Here are the commands, which I have in my $HOME/.exrc map! F /user\.base\.scope^V^Mk4ddF map! L /user\.base\.search^V^Mk4ddL map! V... (1 Reply)
Discussion started by: inditopgun
1 Replies

6. UNIX for Dummies Questions & Answers

Read directory and fill a file with this information

Hello All, Got a question to make a script what reads a directory and put the file names from that directory in a file with some extra text. ls /tempdir output is: file1.gfh file2.txt file4.zzz these file names (always with an extention) must be placed in a line and written to... (2 Replies)
Discussion started by: ToXiQ
2 Replies

7. UNIX for Advanced & Expert Users

How to read an Xml record contained in a file--urgent

Hi I have an xml file which has multiple xml records.. I don't know how to read those records and pipe them to another shell command the file is like <abc>z<def>y<ghi>x........</ghi></def></abc> (1st record) <jkl>z<mno>y<pqr>x........</pqr></mno></jkl> (2nd record) Each record end... (4 Replies)
Discussion started by: aixjadoo
4 Replies

8. Shell Programming and Scripting

Urgent: How to eliminate special symbols in a file and how to read it

Hi, I have file called suppliersList.txt --------------------------------- 112|MIMUS|krish@google.com 113|MIMIRE|krish@google.com 114|MIMCHN|krish@google.com 115|CEL|krish@google.com 108|UGEN|krishn@google.com 109|SLAND|krish@google.com i have 3 varibale ------------- no Name... (4 Replies)
Discussion started by: kittusri9
4 Replies

9. Programming

How to read and write directory or file contents in c++ ?

Dear Friends, I m beginner unix programmer. I want to know, how to read and write directory or file contents in c++ ? (3 Replies)
Discussion started by: namrata5
3 Replies
Login or Register to Ask a Question