Pages

Thursday, April 21, 2016

Linux Bash Scripts - Exercise

  • Create a script "/tmp/string_input_validator.sh" with executable by all such a manner 
        - with input "hello" output should be "Welcome to string validator"
        - with input "bye" output should be "Thank you for using string validator"
        - with input any other value output should be "hello|bye"
        - with no input, output should be "No argument provided, script requires argument"
  • Create a script to convert time-stamp in EPOC/UNIX format to normal format
        - with input EPOC/UNIX format value (i.e.  1448337029  ) output should be corresponding normal time stamp
        - with input any other value output should be "Input not in EPOC/UNIX format"
        - with no input, output should be "No argument provided, script requires argument"
  • Create a script to convert time-stamp in normal format to EPOC/UNIX format 
        - with input normal format value (i.e.  23 Nov 2015 09:50:29   24 hour clock ) value output should be corresponding EPOC/UNIX stamp
        - with input any other value output should be "Input not in normal format value (i.e.  23 Nov 2015 09:50:29   24 hour clock )"
        - with no input, output should be "No argument provided, script requires argument"
  • Create a script to find difference between two normal format time stamp values  
        - with input two normal format value (i.e.  23 Nov 2015 09:50:29   24 hour clock ) values output should be difference in HH:MM:SS format (i.e. hours:minutes:seconds)
        - with only one input value, output should be "One argument provided, script requires two arguments"
        - with no input, output should be "No argument provided, script requires two arguments"
  • Create a script /tmp/create_bulk_users.sh for creating users from userlist.cfg file.
        - Create /tmp/userlist.cfg file with below content.
           user1
           user2
           user3
        - when userlist as first argument provided it will create all the users as per users name specify in userlist.cfg file and all users should have login shell set to /bin/nologin. 
        - if other argument provided it will display "Invalid file name" output.
        - if not providing any argument it will display "No argument provided, script requires argument"
  • Create a script to display type of a file provided in input
        - when input is provided as absolute path of file name output should be "File _____ is a XXXX file" where XXXX can be Link File/Regular File/Block File/Character File/Socket File/Named Pipe File and _______ is the input filename
        - input should be always file name with absolute path 
        - if input file does not exists output should be "File ______ not found", where _______ is the input filename
        - if not providing any argument it will display "No argument provided, script requires argument"
  • Create a script to display details of user provided in input
        - Input to script is user name, based on provided input  script should check for presence of that user on server
        - if user not present it should give message as "User ______ not present on server"
        - if user is found then it should display below information
          UID, GID, home directory, login shell.
          User's account expiry date
          User's password expiry date
  • Create a script for file system backup with below criteria
        - Backup should be taken on central server
        - Backup is to be taken daily at 9 AM IST and two copied of recent backups are to be maintained
        - Script should be able to read Remote server IP and Remote server directory to be backed up from a configuration file in order to handle future additions and removals
        -  Script should send an email alert for success and failure of backup     
  • Create a script for MySQL database instances backup
        - Backup should be generated using mysqldump command
        - Backup is to be taken daily at 9 AM IST and two copied of recent backups are to be maintained
        - Script should be able to read database name, socket file, port, username password of database to be backed up from a configuration file in order to handle future additions and removals
        -  Recent 10 database backups should be maintained by script      
        -  Script should send an email alert for success and failure of backup        
  • Create a script httpd restart
        - Script should be scheduled in and to be executed using normal user
        - Script should run on alternate days at 5AM IST
        - Script should capture logs of cron and maintain them for historical logs checkup.
        - Script should send an email alert for failure in httpd restart    
  • Create a Script to backup file or folder in a folder on local machine from a folder hosted on local machine
        - input argument usage
        - input argument validation
        - cp/rsync command usage

  • Create a Script to backup file or folder in a folder on local machine from a folder hosted on local machine

        - read input from a file
        - input value validation
        - cp/rsync command usage
        - while/for loop usage

  • Create a Script to backup file or folder in a folder on local machine from a folder hosted on remote machine 

        - input argument usage
        - input argument validation
        - scp/rsync command usage

  • Create a Script to backup file or folder in a folder on local machine from a folder hosted on local machine

        - read input from a file
        - input value validation
        - cp/rsync command usage
        - while/for loop usage

  • Creat a Script to backup file or folder in a folder on local machine from a folder hosted on local/remote machine

        - input argument usage
        - input argument validation
        - cp/scp/rsync command usage based on validation of destination type and path

  • Create a Script to backup file or folder in a folder on local machine from a folder hosted on local/remote machine

        - read input from a file
        - input values validation
        - cp/scp/rsync command usage based on validation of destination type and path
        - while/for loop usage

  • Create a Script to backup file or folder in a folder on remote machine from a folder hosted on local/remote machine

        - input argument usage
        - input argument validation
        - cp/scp/rsync command usage based on validation of destination type and path

  • Create a Script to backup file or folder in a folder on remote machine from a folder hosted on local/remote machine

        - read input from a file
        - input values validation
        - cp/scp/rsync command usage based on validation of destination type and path
        - while/for loop usage

  • Create a Script to backup file or folder in a folder on local/remote machine from a folder hosted on local/remote machine

        - input argument usage
        - input argument validation
        - cp/scp/rsync command usage based on validation of source and destination type and path

  • Create a Script to backup file or folder in a folder on local/remote machine from a folder hosted on local/remote machine

        - read input from a file
        - input values validation
        - cp/scp/rsync command usage based on validation of source and destination type and path
        - while/for loop usage

Home

No comments:

Post a Comment