Sponsored Content
Top Forums Programming Archive script spot a mistake? Post 302993171 by robertkwild on Tuesday 7th of March 2017 11:25:23 AM
Old 03-07-2017
Archive script spot a mistake?

Code:
#!/bin/bash

source=/to_be_archived
dest=/archived

    echo "is this archive for an audio tar press (t) or an audio directory press (d)"
    read option

    case $option in

        d)
            cd "$source"

            echo "please specify full path to directory you want to be made into a tar"
            read -e dir

#            echo "please enter ID number ie ID1234"
#            read id

#            echo "please specify where you want the tar file to be stored"
#                       read -e dest

            cd "$dir"

            base=$(basename "$dir")

                echo -e "create "$base" into "$base".tar\n"
                                echo -e "move "$base".tar to "$dest"\n"
#                               echo -e "remove "$base".tar from "$dir"\n"
                echo -e "remove "$base" from "$dir"\n"

                                        echo "is this information correct, press (y) or press (n)"
                                        read correct

                                        case $correct in

                                                y)
                            echo "the script will now continue";;

                                                n)
                            echo "please re-run the script inputting correct details"
                                                        exit;;

                                                *)
                            echo "invalid selection, please re-run the script"
                                                        exit;;

                                        esac                

            date >> /inventories/"$base".csv
            echo "" >> /inventories/"$base".csv
#            echo -e ""$id"\n" >> /inventories/"$base".csv
            echo -e ""$dir"\n" >> /inventories/"$base".csv
            echo -e "how many files = `find . -type f | wc -l`\n" >> /inventories/"$base".csv
            echo -e "size of directory = `du -sh`\n" >> /inventories/"$base".csv
            ls -R >> /inventories/"$base".csv
            
            cd ..

            if ! tar -cf "$base".tar "$dir" ; then
                echo "something went wrong with the tar, please do manually"
                exit
            fi

            if ! mv "$base".tar "$dest" ; then
                echo "something went wrong with the move, please do manually"
                exit
            fi

#            if ! rm -f "$base".tar ; then
#                echo "something went wrong with the rm -f command, please do manually"
#                exit
#            fi

            if ! rm -rf "$dir" ; then
                echo "something went wrong with the rm -rf command, please do manually"
                exit
            fi;;

        *)

            echo "invalid selection, please re-run the script"
            exit;;

    esac

can anyone spot the mistake as when i run the script it cant make the tar

many thanks,

rob
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Archive script old files

Hi All, Im trying to write a script to archive files based on the date the files were created. For example, if a group of files were created on 23rd August,I would have 230806.tar. I have a problem,I want the script to read a separately created file(readarchive.txt) to look for the path to... (1 Reply)
Discussion started by: kayarsenal
1 Replies

2. Shell Programming and Scripting

Archive script

hi guru, can advise how to construct a housekeeping script using perl for the following ? find /var/tmp/logs -name "si*" -type f -exec gzip -f {} \; find /var/tmp/logs -name "*.gz" -type f -exec mv -f {} /var/tmp/log \; I found out those are not working in shell at when put them on... (1 Reply)
Discussion started by: rauphelhunter
1 Replies

3. Shell Programming and Scripting

script help .. archive

Hi All We have a landing directory where source system puts files.There are variable number of files and the file names are also varying.Each files successful transmission is identified by a .done file.If file name is xyz.dat then the confirmation file will be xyz.dat.done. I want to... (1 Reply)
Discussion started by: dr46014
1 Replies

4. Shell Programming and Scripting

Need some help with an archive script

I'm not sure how to solve the $month-1 thingy or the foreach sentence, so I need some help./* folders = folder1 folder2 folder3 folder4 folder5 */ month=`date +%m` if($month == 01) { prev_month = 12 } else { prev_month =... (7 Replies)
Discussion started by: JKMlol
7 Replies

5. Shell Programming and Scripting

need help archive script

Hi all, I am new to linux and scripting so please forgive me. I need to create a script that will archive files but the max size of the archive need to be 500mb or under. I know about the archiving with parts but i want all the archives as individual archives. Can anyone point me in the correct... (7 Replies)
Discussion started by: craig0
7 Replies

6. Shell Programming and Scripting

Can anyone find the mistake in this script file

#!/bin/ksh db_user=`echo $DB_USER_NAME` db_pwd=`echo $DB_PASSWORD` db_sid=`echo $TWO_TASK` sqlplus -s $db_user/$db_pwd@$db_sid << EOF a = select ACK_PARTY_NAME,bus_event_seq_nbr from bus_event where ack_party_name like 'MOVE_USAGE_DAEMON%' and bus_event_seq_nbr='3969094' set -- echo $a |... (17 Replies)
Discussion started by: rkrish
17 Replies

7. Windows & DOS: Issues & Discussions

Archive Unix script to Batch script

Hi All, I have a requirement to archive processed file and retain the archive based on the quantity.. but this is in windows. I have written a drafted shell script, and would like to have it translated into Batch script.. Please... Below is the drafted shell script ... (2 Replies)
Discussion started by: Dave Null
2 Replies

8. UNIX for Dummies Questions & Answers

Can anyone help me to spot my mistake?

Hi there can anyone help me to spot my mistake and please explain why it appears My code : #!/usr/bin/gawk -f BEGIN { bytes =0} { temp=$(grep "datafeed\.php" | cut -d" " -f8) bytes += temp} END { printf "Number of bytes: %d\n", bytes } when I am running ./q411 an411 an411: ... (6 Replies)
Discussion started by: FUTURE_EINSTEIN
6 Replies

9. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

10. Shell Programming and Scripting

Script to archive logs and sftp to another archive server

Requirement: Under fuse application we have placeholders called containers; Every container has their logs under: <container1>/data/log/fuse.log <container1>/data/log/fuse.log.1 <container1>/data/log/fuse.log.XX <container2>/data/log/fuse.log... (6 Replies)
Discussion started by: Arjun Goswami
6 Replies
LIBBASH(7)							  libbash Manual							LIBBASH(7)

NAME
libbash -- A bash shared libraries package. DESCRIPTION
libbash is a package that enables bash dynamic-like shared libraries. Actually its a tool for managing bash scripts whose functions you may want to load and use in scripts of your own. It contains a 'dynamic loader' for the shared libraries ( ldbash(1)), a configuration tool (ldbashconfig(8)), and some libraries. Using ldbash(1) you are able to load loadable bash libraries, such as getopts(1) and hashstash(1). A bash shared library that can be loaded using ldbash(1) must answer 4 requirments: 1. It must be installed in $LIBBASH_PREFIX/lib/bash (default is /usr/lib/bash). 2. It must contain a line that begins with '#EXPORT='. That line will contain (after the '=') a list of functions that the library exports. I.e. all the function that will be usable after loading that library will be listed in that line. 3. It must contain a line that begins with '#REQUIRE='. That line will contain (after the '=') a list of bash libraries that are required for our library. I.e. every bash library that is in use in our bash library must be listed there. 4. The library must be listed (For more information, see ldbashconfig(8)). Basic guidelines for writing library of your own: 1. Be aware, that your library will be actually sourced. So, basically, it should contain (i.e define) only functions. 2. Try to declare all variables intended for internal use as local. 3. Global variables and functions that are intended for internal use (i.e are not defined in '#EXPORT=') should begin with: __<library_name>_ For example, internal function myfoosort of hashstash library should be named as __hashstash_myfoosort This helps to avoid conflicts in global name space when using libraries that come from different vendors. 4. See html manual for full version of this guide. AUTHORS
Hai Zaar <haizaar@haizaar.com> Gil Ran <ril@ran4.net> SEE ALSO
ldbash(1), ldbashconfig(8), getopts(1), hashstash(1) colors(1) messages(1) urlcoding(1) locks(1) Linux Epoch Linux
All times are GMT -4. The time now is 01:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy