Sponsored Content
Top Forums Shell Programming and Scripting Help rewriting my KSH-script... Post 302226556 by linsto on Tuesday 19th of August 2008 08:40:28 AM
Old 08-19-2008
Question Help rewriting my KSH-script...

Hi!

I'm a beginner at scripting, but have managed to complete a working KSH-script.. Smilie

But since this is going to production i a few weeks, I would like to optimize it and make it better structured!

The idéa of the script is to collect data from the database, put it in a file, and then ftp it to another system.

The file has to look like this, $FILE:
0705959226:0616319971
0705989262:0686317272
0705919275:0656319473
0730907151:066616145


But from spooling the result from sqlplus I got this (and I have to get rid of emty spaces and lines, and non numeric lines)
Numbers.lst:
0705959226 :0616319971

0705989262 :0686317272
0705919275 :0656319473

185 rows selected.



So there is a bit mixturing with the file to make it look good.

The script I made look like this, and it is the red part that I'm frustrated over! It has to be done in a better way:

#!/usr/bin/ksh
#

#Set alias for running enviromet variables
. /.profile

DATA_FILES_DIR=/data_files/Numbers
FILE=Numbers_`date '+%Y%m%d'`
FTPSERVER=
FTPLOGIN=
FTPPASS=
FTPDIR=

export DATA_FILES_DIR FILE FTPSERVER FTPLOGIN FTPPASS FTPDIR

sqlplus /nolog @/scripts/Numbers.sql

cd $DATA_FILES_DIR

awk 'NF >= 2' Numbers.lst > Numbers.tmp
awk 'NF <= 2' Numbers.tmp > Numbers.tmp2
awk '{ print $1 $2 }' Numbers.tmp2 > $FILE
rm Numbers.tmp*
rm Numbers.lst


#FTP file to another system

ftp -n -i $FTPSERVER <<EOF
user $FTPLOGIN $FTPPASS
cd $FTPDIR
put $FILE
quit
EOF

mv $FILE processed




Any idéas or inputs?
Please...

/Linda
 

10 More Discussions You Might Find Interesting

1. IP Networking

Squid Proxy URL rewriting

I have an architecture as below <> <> There is a program in the AIX server which sends SMS to the internet, by sending HTTP request to the SMS processing server. Like, http://smsserver/mysms=test However the application does not have an option to specify where the Proxy server... (1 Reply)
Discussion started by: firdousamir
1 Replies

2. Shell Programming and Scripting

import var and function from ksh script to another ksh script

Ih all, i have multiples ksh scripts for crontab's unix jobs they all have same variables declarations and some similar functions i would have a only single script file to declare my variables, like: var1= "aaa" var2= "bbb" var3= "ccc" ... function ab { ...} function bc { ... }... (2 Replies)
Discussion started by: wolfhurt
2 Replies

3. UNIX for Dummies Questions & Answers

Rewriting a word from location

I am using: ..to get the word that is being searched. What I am looking to do, is to rewrite the word and us it in css: Sort of like this javascript: Hopefully I am making myself clear. Any ideas how I could do this? (1 Reply)
Discussion started by: marringi
1 Replies

4. UNIX for Advanced & Expert Users

postfix sender address rewriting

Hi, I have a postfix server that relays to an exchange server. All of my unix/linux systems send to this server, the problem is the form the mail is sent with, the sender address is username@hostname.domain.local I need to rewrite every sender address to unix@maildomain.com for... (0 Replies)
Discussion started by: funksen
0 Replies

5. Shell Programming and Scripting

Help with grep (reWriting it in another way.)

Hello everyone!! Nice do be apart of your forum. I am not very good at unix and thats why i need your help i have this project where i have to simulate a grep command without using grep thought. I have to simulate grep <parameters> <file> grep <parameters> <file> grep <parameters> <file>... (6 Replies)
Discussion started by: kenshin88
6 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

Rewriting file paths in XML file within bash script

Hi guys, I'm working on a large set of scripts to move files around several servers and manipulate them for our staff. Basically we're shooting things, the videos hit a server and then need organised due to the language they've been shot in. Our XML (designed for Apple's Final Cut Pro) is right... (6 Replies)
Discussion started by: omfgbunnies
6 Replies

8. IP Networking

Transparent Proxy with URL Rewriting

All traffic on the LAN is routed through a single machine and filtered using iptables. I'd like to redirect this traffic to a transparent proxy running on the same machine that will rewrite the URL if it matches a specified regex, in which case the user will be redirected to a local server. In... (0 Replies)
Discussion started by: crottyan
0 Replies

9. Shell Programming and Scripting

Rewriting GNU uniq in awk

Within a shell script I use uniq -w 16 -D in order to process all lines in which the first 16 characters are duplicated. Now I want to also run that script on a BSD based system where the included version of uniq does not support the -w (--check-chars) option. To get around this I have... (7 Replies)
Discussion started by: mij
7 Replies

10. UNIX for Beginners Questions & Answers

Reverse prior batch job (without simply rewriting the script)

So, let's say I have a usual batch rename file like this: and I'd like to have a secon bat file, that can /reverse" the first. BUT, I don't want to simply "rewrite" it like move hello 254352426 but rather, have the new script take the source and destination and reverse it somehow... (6 Replies)
Discussion started by: pasc
6 Replies
FACTOR(6)							 BSD Games Manual							 FACTOR(6)

NAME
factor, primes -- factor a number, generate primes SYNOPSIS
factor [-h] [number ...] primes [-h] [start [stop]] DESCRIPTION
The factor utility will factor positive integers. When a number is factored, it is printed, followed by a ':', and the list of factors on a single line. Factors are listed in ascending order, and are preceded by a space. If a factor divides a value more than once, it will be printed more than once. When factor is invoked with one or more arguments, each argument will be factored. When factor is invoked with no arguments, factor reads numbers, one per line, from standard input, until end of file or error. Leading white-space and empty lines are ignored. Numbers may be preceded by a single '+'. Numbers are terminated by a non-digit character (such as a newline). After a number is read, it is factored. The primes utility prints primes in ascending order, one per line, starting at or above start and continuing until, but not including stop. The start value must be at least 0 and not greater than stop. The stop value must not be greater than the maximum. The default and maximum value of stop is 3825123056546413050. When the primes utility is invoked with no arguments, start is read from standard input and stop is taken to be the maximum. The start value may be preceded by a single '+'. The start value is terminated by a non-digit character (such as a newline). DIAGNOSTICS
negative numbers aren't permitted illegal numeric format start value must be less than stop value Result too large BUGS
factor cannot handle the ``10 most wanted'' factor list, primes will not get you a world record. primes is unable to list primes between 3825123056546413050 and 18446744073709551615 since it relies on strong pseudoprime tests after siev- ing, and nobody has proven how many strong pseudoprime tests are required to prove primality for integers larger than 3825123056546413050. BSD
October 10, 2002 BSD
All times are GMT -4. The time now is 06:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy