First go at scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting First go at scripting
# 1  
Old 07-24-2009
First go at scripting

I am in the process of writing my first script using Bash and not sure where to go from here and wondered if you could help a bit…. I am trying to go through Connect Direct files and search for a specific date (20090714) and type (CEC,CEP,CEM) to pull out of the file. If it is archived I need to check the directory to see if it is a zipped file (history files named like this: STATARCH-20090714-20090714.Z ) unzip the file and rename to normal name (like this: a S20090721.081) and then tie into the piece explained above. Any input would be grateful!

Last edited by freddie88; 07-24-2009 at 10:17 AM..
# 2  
Old 07-24-2009
show us what you've tried so far and where you've problems...
# 3  
Old 07-24-2009
What are/is "Connect Direct files"? What have you done so far?
# 4  
Old 07-24-2009
Code:
#!/bin/bash
clear
echo "Please enter the date for CD info wanted: \c"
read rrd_date
echo "Please enter CEC CEM or CEP: \c"
read file_name
sleep 2
# Create the output file with CEC CEP or CEM information
echo "Creating $file_name file"
cd /opt/cdunix/work/vcndm
sleep 2
grep $file_name S2*$rrd_date.* >~/rrd$rrd_date$file_name               
echo "output rrd$rrd_date$file_name file created"
sleep 2
FILE=~/rrd$rrd_date$file_name
echo $FILE
FS="|"
while read line
do
        # store field 1
        F1=$(echo $line | cut -d$FS -f1)
        echo "$F1" >>~/cdrrdout$rrd_date$file_name
        # store field 2
        F2=$(echo $line | cut -d$FS -f2)
        echo "$F2" >>~/cdrrdout$rrd_date$file_name
        # store field 18
        F18=$(echo $line | cut -d$FS -f18)
        echo "$F18" >>~/cdrrdout$rrd_date$file_name
        # store field 19
        F19=$(echo $line | cut -d$FS -f19)
        echo "$F19" >>~/cdrrdout$rrd_date$file_name
        echo " " >>~/cdrrdout$rrd_date$file_name
done < $FILE
echo "cdrrdout$rrd_date$file_name has been created"


This part works... just not sure how to incorporate if the file was archived (zipped) into this process.
Thanks!

---------- Post updated at 08:49 AM ---------- Previous update was at 08:47 AM ----------

Connect Direct/NDM file transmissions

Next time use CODE-tags when posting code, data or logs to enhance readability and to preserve foramtting like indention etc., ty.

---------- Post updated at 09:40 AM ---------- Previous update was at 08:49 AM ----------

was also wondering if egrep would be better to use instead of grep when looking at the file?

Last edited by zaxxon; 07-24-2009 at 10:58 AM.. Reason: daily CODE tags
# 5  
Old 07-28-2009
guess no one wants to help me......Smilie
# 6  
Old 07-28-2009
you can check the file extention by using..
Code:
echo ${file_name##*.}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

Perl scripting or shell scripting?

i am going to study any one of the scripting languages mentioned above(shell 0r perl scripting) . Which is having more scope for a fresher? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

2. What is on Your Mind?

Shell Scripting vs Perl scripting

Gents, I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Discussion started by: Pouchie1
2 Replies

3. Android

Android Scripting Environment: Shell Scripting and Android

I just upgraded to Android 2.2 from 2.1. The GPS issue that was troublesome in 2.1 seems to have been fixed. Some of web browsing seems faster, but it could just be my connection is better today ;) Flash works in some browsers but not very good and it is too slow for Flash apps designed for... (0 Replies)
Discussion started by: Neo
0 Replies

4. What is on Your Mind?

Shell scripting vs Perl scripting

Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to... (14 Replies)
Discussion started by: Pouchie1
14 Replies

5. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

6. UNIX for Dummies Questions & Answers

Scripting Help

Hello all. Like Ive stated before, I am new to world of Unix. I was given the tast to create a script that will concatenate 20 files into one file. I know that the cat command is to be used but I am looking for something to get started on. Again, basically I need to wrtie a script that whill... (3 Replies)
Discussion started by: ndoggy020
3 Replies

7. UNIX for Advanced & Expert Users

Need help on scripting

in unix bc command is used as calculator and also for conversion, i want to convert 5f to decimal. but bc dont consider 5f as hex value it considers 5F as hex value. I get 5f from other iteration so i cant change that f to F...is there any way to convert 5f to decimal ot 5f to 5F :rolleyes: (2 Replies)
Discussion started by: abhinandantn
2 Replies

8. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies

9. Shell Programming and Scripting

scripting guru's pls help me with scripting on AIX

can someone pls help me with the script for a files coming from one system to a particular directory and i want to write a script to move those files to another directory on different system by renaming the files... pls someone help me on this... thanking in anticipation.... (1 Reply)
Discussion started by: thatiprashant
1 Replies

10. AIX

New to scripting

We have a scripting requirement, Background: On a particular path, we compress a load of log files into tar.gz. This is done on an hourly basis throughout the day and it produces files of the following format, 2005-08-05-00-021031.tar.gz as an example. This is done by a script. We need: ... (2 Replies)
Discussion started by: rajesh_149
2 Replies
Login or Register to Ask a Question