Shell scripts problem...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell scripts problem...
# 1  
Old 11-25-2005
Question Scripts problem...

Hi,

sprt.sh

Code:
#!/bin/ksh
###############################################################################
# -----------------------------------------------------------------------------
#
# ------------------------------------------------------------------------------
################################################################################                                                                                                              
# Variable list                                                 
FILE="/usr/errors/errors_07/unknown_07.txt"             
MAILING_LIST="mailbox_07.cfg"                                                   
LIST_SITE=`cut -d# -f1 $FILE |sort -u`                                       
PATH="/usr/errors/errors_07/rejet_07/"                                      
UNLOAD="dbaccess katali ../error_07_output.sql"                                   
                                                                             
# unload unknown_07.txt                                                      
$UNLOAD                                                                      

# Extract site                                                               
for SITE in ${LIST_SITE}                                                     
do                                                                           
                                                                             
# Extract SITE                                                               
echo "Extraction infos for centre $SITE..."                            
                                                                             
echo "Hi, \n" >$PATH$SITE.txt                                          
echo " This is list of all errors found :\n" >>$PATH$SITE.txt
echo "Clothes   Colors   Type     Age         Eyes     Hair  \n" >>$PATH$SITE.txt      
                                                                             
grep $SITE $FILE |sed 's/\#/    /g' >>$PATH$SITE.txt                   
                                                                             
echo "\n" >>$PATH$SITE.txt                                                 
echo "This is real errors from you ? \n" >>$PATH$SITE.txt

echo "Where is send ? \n" >>$PATH$SITE.txt

echo "CDLT.\n" >>$PATH$SITE.txt
                                                                             
# Send Mail                                                                  
TO=`grep ^$SITE $MAILING_LIST|cut -d: -f2`                                   
                                                                             
# Convert file in DOS mode...                                       
unix2dos -ascii $PATH$SITE.txt $PATH$SITE.txt 2>/dev/null                
                                                                             
echo "Send to $PATH$SITE.txt a $TO"                              
SEND=`cat $PATH$SITE.txt`                                                  
                                                                             
# Send mail auto to center                                        
mailx -r myemail_is_here@testers.com -s "$SITE - Real Errors - Error 07" myemail_is_here@testers.com ${TO} < $PATH$SITE.txt 
                 
done

error_07_output.sql

Code:
unload to /usr/errors/errors_07/unknown_07.txt              
select clothes[1,4],colors,type,date,hair         
from kalatina                                                     
where errors_za="07"                                                  
order by 6, 1,2,3,4

unknown_07.txt

Code:
CELI#MLT#L65041205#LONG#24/11/2005#BRO#     
NAFN#YELLOWBL#K354945911#04C05#22/11/2005#COL#
GAP#BLEUE#05382806#SMALL#12/10/2005#PIN#  
GAP#BLEUE#704371650#MEDIUM#20/10/2005#WHI#   
PI*A##5868142897#UNKOWN#01/11/2005#RED#        
PI*A##7552242751#0QV75#04/08/2005#DEP#        
PI*A#BROWN#H638042337#04B05#24/11/2005#SAM#  
PI*A#BROWN#L135034575#04C05#23/11/2005#UNK#


mailbox_07.cfg

Code:
CELI:email_is_here@betatester.com
NAFN:email_is_here@betatester.com
GAP:email_is_here@betatester.com
PI*A:email_is_here@betatester.com

Hi,

someone can help me, when i run my script, sprt.sh, this unload a txt file at here /usr/errors/errors_07/unknown_07.txt and split by clothes ( in my exampe
CELI ) and then send a email via sprt.sh and looks in mailbox_07.cfg aslo for send other mail at persons.

my probleme is when i have a file like unknown_07.txt with :

Code:
CELI#MLT#L65041205#LONG#24/11/2005#BRO#     
NAFN#YELLOWBL#K354945911#04C05#22/11/2005#COL#
GAP#BLEUE#05382806#SMALL#12/10/2005#PIN#  
GAP#BLEUE#704371650#MEDIUM#20/10/2005#WHI#   
PI*A##5868142897#UNKOWN#01/11/2005#RED#        
PI*A##7552242751###DEP#        
PI*A#BROWN#H638042337#04B05#24/11/2005#SAM#  
PI*A#BROWN###23/11/2005##

PI*A is splited and sent via mail, but when i receive mail is empty of contains


So there are a errors ( PI*A##5868142897#UNKOWN#01/11/2005#RED# ) when there are 2 or more this "##" this make a empty email,
so how i can remove all "#" and remplace with a 1 space ?????


Plateform : Sun 5.8

Last edited by parola; 11-25-2005 at 09:22 AM..
# 2  
Old 11-25-2005
Quote:
Originally Posted by parola
so how i can remove all "#" and remplace with a 1 space ?????
You're joking, aren't you?

sed 's/##*/<spc>/g'

Replace the "<spc>" with a literal space.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem in two scripts

I wrote one script it is showing wrong out but i wrote another script it is showing right out. I really don't know the difference. first-script-showing mistake. #!/bin/bash echo "Counting the Databases" countp1=`ps -ef |grep pmon |grep -v grep | wc -l` echo $countp1 #countp=3 if ... (3 Replies)
Discussion started by: learnbash
3 Replies

2. Homework & Coursework Questions

Problem with Shell Scripts deleting text in files.

Me and a friend are working on a project, and We have to create a script that can go into a file, and replace all occurances of a certain expression/word/letter with another using Sed. It is designed to go through multiple tests replacing all these occurances, and we don't know what they will be so... (1 Reply)
Discussion started by: Johnny2518
1 Replies

3. Shell Programming and Scripting

Shell performance problem with locating scripts

I am currently trying out MKS Toolkit C Shell, and I've no problems with it until I try add directories to PATH that are located on a network drive. When I do that, the shell performance slows down significantly and no longer runs fast. In fact, it takes seconds for something that should take... (1 Reply)
Discussion started by: vas28r13
1 Replies

4. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

5. Shell Programming and Scripting

Problem with ftp scripts and cron

Need some help / advice with the follow script... Basically i have an FTP server that connects to other ftp servers and sends and downloads files every few hours or so. There are 12 different accounts that all have 2 scripts each, one to send and one to receive. Below is an example send script... (1 Reply)
Discussion started by: mokachoka
1 Replies

6. Shell Programming and Scripting

Cron and multiple scripts problem.

Hello All, I have 3 scripts namingly 1X 2X and 3X. I have one directory ABC created which contains some 40 sub directories. I have one input file in the below format.The input file resides in ABC directory. Inputfile format; subdirectoryname date subdirectoryname1 date subdirectoryname2... (1 Reply)
Discussion started by: RSC1985
1 Replies

7. UNIX for Dummies Questions & Answers

Script Problem-Processing multiple scripts

Hi All, I have four scripts to run. My 1st script will make script2 and script3 to run. I am setting a cron job for this script1 to run continuously. This script1 will check for 2 text files and based on the existance of those text files it will initiate the script2 and script3. Now my doubt... (2 Replies)
Discussion started by: RSC1985
2 Replies

8. UNIX for Dummies Questions & Answers

PHP scripts problem!

Hi, I've configured a server with Debian Etch 4.0. I followed these instructions: Install and Configure Apache2 with PHP5 and SSL Support in Debian Etch -- Debian Admin But when I try to launch a php script with phpinfo() in my browser, It showed me the download manager window.(i.e. wanna to... (9 Replies)
Discussion started by: mjdousti
9 Replies

9. HP-UX

scripts problem

Hi, the only experience I have with Unix is on C360 workstations using 10.20 and Omniback II to restore email with HP Openmail. I have four brand new machines that I am installing the OS and software on, however, their are scripts that were written specifically for our tape process that I have... (13 Replies)
Discussion started by: Asheley Ryan
13 Replies

10. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies
Login or Register to Ask a Question