Sponsored Content
Full Discussion: KSH scripting
Top Forums Shell Programming and Scripting KSH scripting Post 303004525 by leecopper on Tuesday 3rd of October 2017 10:05:19 PM
Old 10-03-2017
Hi Robin,
There is a changes on the scenario, lets say I have a development server A running AIX 7.1 with ip 192.168.82.22 and a windows workstation with ip 192.168.82.44 and the ftp connection is opened.
for server A under the /app/gg/it there will be file generated every hour and another fie generated daily,what i need to do is to find the files lets say from may 2017 till yesterday and gzip it then ftp it over to the workstation assuming the ftp is ok. how should my scripts looks like?
Here I created a script but don't know its was right or wrong as I do not have a chance to test on the real development environment.

Code:
 
  1. #!/bin/bash
  1. cd /app/gg/it
  1. find /app/gg/it -name "Data_to_check_*" -type f -mtime +0 -exec gzip {} \;
  1. find /app/gg/it -name "log_to_check_*" -type f -mtime +0 -exec gzip {} \;
  1. HOST=192.168.82.44
  1. USER=admin
  1. PASS=abc123
  1. DIR1=$(date +"%Y_Data")
  1. DIR2=$(date +'%Y_log")
  1. DADIR="/app/gg/it/"
  1. LODIR="/app/gg/it/"
  1. DAFILE=$(date + "Data_%Y%m%d*.gz")
  1. LOFILE=$(date + "log_%Y%m%d*.gz")
  1. echo "backup file to admin workstation"
  1. ftp -n -v $HOST <<EOF
  1. user "$USER" "$PASS"
  1. prompt
  1. ascii on
  1. mkdir "$DIR1"
  1. cd "$DIR1"
  1. mkdir "$DIR2"
  1. cd "$DIR2"
  1. lcd $DADIR
  1. mput $DAFILE
  1. lcd $LODIR
  1. mput $LOFILE
  1. quit
  1. EOF


Last edited by leecopper; 10-06-2017 at 05:56 AM.. Reason: Converted to formatted numbered list
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

KSH Scripting

Will a shell script written in shell for HP/UX run on Solaris? (1 Reply)
Discussion started by: dstaller
1 Replies

2. Shell Programming and Scripting

Need help with KSH scripting

Hi I need to insert a page break into a file based on matching a phrase in the file. :confused: I am doing this with a ksh script on a Unix box. Any help would be greatly appreciated. Thanks (5 Replies)
Discussion started by: scrappycc
5 Replies

3. Shell Programming and Scripting

ksh scripting help

I have the file as below server1 no dr aix 5300-05-03 9119-595 20-18888 yes ftp-eagle server2 no dr aix 5300-05-03 9119-595 20-18888 yes ftp-eagle server3 yes dr aix 5300-05-03 9119-595 20-18888 yes ftp-eagle server4 ... (1 Reply)
Discussion started by: praveenbvarrier
1 Replies

4. Shell Programming and Scripting

ksh scripting help needed.

I am trying to create a script to manipulate numerous file and at first I thought it would be a simple task but at this point i am ready to break my computer! I am new to unix scripting so hopefully someone out there thinks this is super easy and can help me out! A sample of the problem file is... (2 Replies)
Discussion started by: theqcup
2 Replies

5. Shell Programming and Scripting

Problem with Ksh scripting

Hi, Below is the code for my script #!/bin/ksh for file in "file1.txt" "file2.txt" "file3.txt" "file4.txt" do L="$(tail -1 $file)" NUM=${L%%|*} DAT=${L##*|} echo $NUM echo $DAT done Now here,suppose for file1.txt L will have data like 56|06-07-2010 So, it should be (7 Replies)
Discussion started by: fidelis
7 Replies

6. Shell Programming and Scripting

Help with ksh scripting in AIX

I am looking for a script which does the following Script will run daily. 1.It will get snapshot off all filesystems including nfs mounts, automounts and clearcase mounts. 2.Then it will compare new snapshot with the snapshot created in the previous run. 3.If filesystem exists in... (20 Replies)
Discussion started by: saidiya
20 Replies

7. Shell Programming and Scripting

Help needed in ksh scripting

I got a task to do today, I want to write a script for the following 1) Archive log more than 2 days old 2) Number of days the current Archive logs present 3) Total number of archive logs 4) Size of each archive log 5) When was last successful backup happened? Can I get a general script... (8 Replies)
Discussion started by: Rambo
8 Replies

8. Shell Programming and Scripting

help in ksh scripting in aix

Hello gurus I am looking for a script : We need to generate a file list created by user id on a AIX box. Criteria 1: other than userid : dwimpid & aiadmin Criteria 2: Files older than 2 months ( it can be any user id ). File Path to Look: /project and /project1 Thx silu (7 Replies)
Discussion started by: silu
7 Replies

9. Shell Programming and Scripting

help with ksh shell scripting

I want to run a script that checks the env to see if I'm in a test or prod environment. From the command line I enter echo $host and it returns host name and I can tell by the name if I'm in test or prod. When I run the command from a script I get "not found" What's wrong with the script? if ... (2 Replies)
Discussion started by: Bperl1967
2 Replies

10. Shell Programming and Scripting

ksh scripting

Hi All, Can you please let me know what I missed in the below function? Whenever I try to execute the script i am getting syntax error at line 101 : `fi' unexpected Function is function DELNWE5O { export ORACLE_HOME=/ora00/app/oracle/product/11.2.0/grid_1 export... (9 Replies)
Discussion started by: pvmanikandan
9 Replies
All times are GMT -4. The time now is 01:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy