SCRIPT FORMAT


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SCRIPT FORMAT
# 1  
Old 03-11-2011
SCRIPT FORMAT

Hi I have written a script in bash. It doesn't look like a proper bash script. Please find the script and guide me, how to make it more efficient and lookable code. I have not used any libraries for FTP, becuase I don't have those installed in my Red Hat Linux.

Code:
#!/bin/bash
 
server=192.168.1.100
user=pkg
current_date=`date "+%b%d%Y"`
csi_file="TechProduct.out"
ctc_file="CTCInfo.ou"
 
#Get CSI & CTC Files from FTP Server
 
echo "=========================================================="
echo "Files are being received from csidb2.nj.ssmb.com to stealth"
/export/opt/SCssh/3.7.1_C0/bin/sftp csi@csi.on.com <<GET_FILES
lcd /WEBSERVER_LINK/data_logs/
ls -l pub/csidata/GeneralAppFields_8_1_Feed.out pub/csidata/CtcCatalog_7_3_3_Feed.out
get pub/csidata/GeneralAppFields_8_1_Feed.out
get pub/csidata/CtcCatalog_7_3_3_Feed.out
quit
GET_FILES
echo "Files has been received from csidb2.nj.ssmb.com to stealth"
echo "=========================================================="
  
echo "=========================================================="
echo "Files are being copied to redhat for CSI & CTC Conversion"
copy_files_to_redhat() {
 cd /WEBSERVER_LINK/data_logs/
 ls -lrt GeneralAppFields_8_1_Feed.out CtcCatalog_7_3_3_Feed.out
 scp GeneralAppFields_8_1_Feed.out CtcCatalog_7_3_3_Feed.out pkg@192.168.1.100:/disk01
 ssh -l "pkg" "169.187.172.213" "ls -lrt /disk01/GeneralAppFields_8_1_Feed.out /disk01/CtcCatalog_7_3_3_Feed.out; cd /disk01/csi; php -q ./csifeedconversion.php; ls -lrt /disk01/TechProduct.out; cd /disk01/ctc; perl ctcfeedconversion.pl; ls -lrt /disk01/ctc/CTCInfo.out"
}
echo "Files are copied to redhat for CSI & CTC Conversion"
echo "=========================================================="
 
copy_files_to_redhat
backup_files
 
echo "=========================================================="
echo "Files are being BACKED UP in stealth server"
backup_files() {
    cd /WEBSERVER_LINK/data_logs
    mv csi_file csi_file."BACKUP".current_date
    mv ctc_file cct_file."BACKUP".current_date
}
echo "BACKUP COMPLETED"
echo "=========================================================="
 
 
echo "=========================================================="
echo "Files are copied from redhat to stealth after CSI & CTC Conversion"
/export/opt/SCssh/3.7.1_C0/bin/sftp pkg@192.168.1.100 <<PUT_FILES
lcd /WEBSERVER_LINK/data_logs
get /disk01/TechProduct.out
get /diso01/ctc/CTCInfo.out
ls -l TechProduct.out CTCInfo.out
quit
PUT_FILES
echo "Files copied Successfully"
echo "=========================================================="

Script is working fine. But it doesn't look like bash script. It looks like some group of commands. Please reply how to make this code more lookable.

Last edited by pludi; 03-11-2011 at 03:59 AM..
# 2  
Old 03-11-2011
What do you mean by "it does not look like a bash script"? It sure looks looks a bash script to me.
# 3  
Old 03-11-2011
I think what the OP wants is someone to explain and add comments to the script so they will better understand what the script is doing.

Best wishes.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

2. Shell Programming and Scripting

awk Script to format output

Hi all, I'm fairly new to this and learning along the way, so bare with me... I'm trying to format the output from a script to be more read-friendly. The output contains more servers and more processes but for as example it will do: Server: Test1 ... (4 Replies)
Discussion started by: Bobsonm
4 Replies

3. Shell Programming and Scripting

Need script for transferring bulk files from one format to text format

"Help Me" Need script for transferring bulk files from one format to text format in a unix server. Please suggest (2 Replies)
Discussion started by: Kranthi Kumar
2 Replies

4. Shell Programming and Scripting

Converting windows format file to unix format using script

Hi, I am having couple of files which i used to copy from windows to Linux, so now in case of text files (CTRL^M) appears at end of line. I know i can convert this windows format file to unix format file by running dos2unix. My requirement here is that i want to do it automatically using a... (5 Replies)
Discussion started by: sarbjit
5 Replies

5. UNIX for Advanced & Expert Users

Date format script (in .sh)

Could anyone suggest me on how to write unix script for displaying yesterdays date ie. if today is 2nd Mar then when i run .sh script i should get displayed as "01-Mar-2010". (5 Replies)
Discussion started by: Nithin
5 Replies

6. Solaris

format file using shell script

my question "format file using shell script " is not a homework. bad guess. my actual file is much more complex. the requirement is to format the file before i can read it from SAP. so i'd appreciate if any inputs can be provide. i've tried most of the commands like tr and sed and nawk, no... (2 Replies)
Discussion started by: balajim
2 Replies

7. Solaris

format file using shell script

Hi All, I am new to shell scripts. I have a requirement to change the format of a file. Here is the original file: #student layout student_name student_class student_subject david 5 chemistry paul 4 physics steve 6 mathematics This is the format i need: k1,david,5,chemistry... (1 Reply)
Discussion started by: balajim
1 Replies

8. Shell Programming and Scripting

Script output format

Hi Gurus, 1. I have a script to run a SQL report. The script ran fine, but the format of the output is not satisfactory in that I see too much white space in between the lines in the output file (logfile). Please see the example below: 010192S.CD 01117CV000A.CD ... (6 Replies)
Discussion started by: syang68
6 Replies

9. Shell Programming and Scripting

script for format a file

is there any way to format a file by just removing first line and last line from the file. my file is like test.txt 12may2004,20may2004,A 123,SCOTT,TIGER,,,,12,12-MAY-2006 124,TIGER,SCOTT,,,,,,, .... ... 163,cscssaa,abc,,,,12,12-MAY-2006 END my requirement is to produce the same file... (1 Reply)
Discussion started by: u263066
1 Replies

10. Shell Programming and Scripting

Korne Script for format file

Hi All, I am not too familiar with Korne script so I need as much help as possible on this ;) What I want to do is: from the excel file on my computer, I want to take certain field from this xls file and put it in txt or cvs format in specific width column. Then fpt this file into the server. ... (51 Replies)
Discussion started by: CamTu
51 Replies
Login or Register to Ask a Question