Sponsored Content
Full Discussion: ctrl-c in shell script
Top Forums Shell Programming and Scripting ctrl-c in shell script Post 302666209 by nareshkumar522 on Wednesday 4th of July 2012 02:03:58 AM
Old 07-04-2012
Here is the code for perl script.

The perl script is inbuilt script which I am using to list pools

(LP) List Pools

Below is the code of perl


Code:
Enter the action you would like to perform: ';
                chomp ($opt{F} = <STDIN>);
#               $opt{F} = uc($opt{F});
        } until ($opt{F} =~ m/^A$|^M$|^R$|^D$|^L$|^LP$|^Lp$|^Ls$|^LS$|^CS$|^DS$|^RS$|^C$|^B$/);
        return;
}

# Validate a pool supplied on the cmd line
sub _validate_pool {
        my ($args) = shift;
        # $args->{pools}         => the pool data from the filer.
        # $args->{pool_to_check} => The pool to verify.

        # Go through the pool data and if the pool_to_check matches the data pulled from the filer.
        foreach my $pool_data (@{ $args->{pools} }) {
#               if ($pool_data =~ m/^$args->{pool_to_check}\s+/ && $pool_data =~ m/\s+online\s+/) {
                if ($pool_data =~ m/^$args->{pool_to_check}\s+/) {
                        return 1;

                }
        }
        print "\nWARNING:  Invalid pool specified\n\n";
        return 0;
}

# If the user doesn't specify the pool
sub _get_pool {
        my $ref = shift;
        my @pools = @{ $ref };
        my $input;

        do {
                print "\nThe following pools are online and available:\n";
                printf("%-10s %10s    %10s    %10s    %10s    %10s %% %10s %%\n", "Name", "Total", "Allocated", "Used", "Available", "Alloca                 ted", "Used");
                print("-"x95);
                print "\n";
                foreach my $pool (@pools) {
                        my (@data) = split(/\s+/, $pool);
#                       if ($data[5] eq "online") {
                                printf("%-10s %10d GB %10d GB %10d GB %10d GB %10d %% %10d %%\n", $data[0], $data[1] / 1048576, $data[2] / 1                 048576, $data[3] / 1048576, $data[4] / 1048576, $data[5], $data[6]);
#                       }
                }
                print "\nEnter the name of the pool you want to use: ";
                chomp ($input = <STDIN>);
        }  until ( &_validate_pool({pools => $ref, pool_to_check => $input}));
        return $input;
}

 

10 More Discussions You Might Find Interesting

1. AIX

Disable ctrl-c,ctrl-d,ctrl-d in ksh script

I wrote a ksh script for Helpdesk. I need to know how to disable ctrl-c,ctrl-z,ctrl-d..... so that helpdesk would not be able to get to system prompt :confused: (6 Replies)
Discussion started by: wtofu
6 Replies

2. Shell Programming and Scripting

Disabling ctrl-Z key inside shell script

Hi I have tried to disable the CTRL-Z key inside a shell(sh) script using the command trap "`echo "Ctrl-Z key disabled"`" 20But I am not able to exit from the script after pressing CTRL-Z key. How to proceed this? Need reply soon (11 Replies)
Discussion started by: suganthic
11 Replies

3. UNIX for Dummies Questions & Answers

scripting Ctrl-D in a shell

Hi, I want to use the "at" command in a loop to start different processes every hour or so, but I don't know how to script a Ctrl-D so I can escape from the "at" after the last command I want to run and then go to the next command in the loop. Example: i=1 while do j=$((i*60)) at... (2 Replies)
Discussion started by: etownbetty
2 Replies

4. UNIX for Advanced & Expert Users

trap ctrl c in shell script

how to trap the ctrl c in unix shell script my script is running in while loop it should not be terminate with ctrl c. if i press ctrl c while running script it shloud ignore the same. please healp.......... thanks in advance (2 Replies)
Discussion started by: arvindng
2 Replies

5. UNIX for Dummies Questions & Answers

alias in bash shell for CTRL + l

Is it possible to create an alias wherein it will use a keystroke. Like to clear the screen in bash i have to use CTRL + l. I want to make an alias 'c' out of this. Thanks. (6 Replies)
Discussion started by: or_knob
6 Replies

6. Shell Programming and Scripting

Ctrl-C or Ctrl-Z causing exit the session

H! I have written script where it need to invoke the perl script in background, then write the pid in temp file then bring back the job to foreground. whenever the Ctrl-C or Ctrl-Z is pressed in the script has to exit and prompt should be dispalyed. but this script causing exit from shell session... (2 Replies)
Discussion started by: jramesh1
2 Replies

7. Shell Programming and Scripting

Write a shell script to find ctrl M and delete them

Hi All, I would like to write a shell script to find Control M charactes and after getting the result i want to delete it. But in the script the following command couldn't work. find . -exec grep -l '^M' {} \; > test.txt ^M is ctrl V and M thanks in advance for any help. (4 Replies)
Discussion started by: jatanig
4 Replies

8. Shell Programming and Scripting

How to handle CTRL+Z or CTRL+C in shells script?

Hi, while executing shell script, in the middle of the process, if we kill the shell script( ctrl+z or ctrl+c), script will be killed and the files which using for the script will be in the folder. How to handle those scenarios. Is there any possibilities, if user breaks the script, I need to... (3 Replies)
Discussion started by: ckchelladurai
3 Replies

9. UNIX for Dummies Questions & Answers

Ctrl-V + Ctrl-J for newline character does not work inside vi editor

Hi friends, I am trying to add a newline char ('\n') between the query and the commit statement in the following shell script. #! /bin/sh echo "select * from tab; commit;" > data.sql I have tried typing in "Ctrl-V + Ctrl-J" combination which has inserted ^@ (NUL) character but the commit... (1 Reply)
Discussion started by: royalibrahim
1 Replies

10. Shell Programming and Scripting

Automation of keyboard inputs..like Ctrl+d and Ctrl+a

Hi..! I'm stuck with my automation of starting a process and keeping it running even after the current ssh session has exited.. So i'm trying to use command 'screen'. which is doing exactly what i wanted, But the problem is automation of the same. i will have to press Ctrl+a and Ctrl+d for... (2 Replies)
Discussion started by: chandana hs
2 Replies
IPPOOL(8)						      System Manager's Manual							 IPPOOL(8)

NAME
ippool - user interface to the IPFilter pools SYNOPSIS
ippool -a [-dnv] [-m <name>] [-o <role>] -i <ipaddr>[/<netmask>] ippool -A [-dnv] [-m <name>] [-o <role>] [-S <seed>] [-t <type>] ippool -f <file> [-dnuv] ippool -F [-dv] [-o <role>] [-t <type>] ippool -l [-dv] [-m <name>] [-t <type>] ippool -r [-dnv] [-m <name>] [-o <role>] -i <ipaddr>[/<netmask>] ippool -R [-dnv] [-m <name>] [-o <role>] [-t <type>] ippool -s [-dtv] [-M <core>] [-N <namelist>] DESCRIPTION
Ippool is used to manage information stored in the IP pools subsystem of IPFilter. Configuration file information may be parsed and loaded into the kernel, currently configured pools removed or changed as well as inspected. The command line options used are broken into two sections: the global options and the instance specific options. GLOBAL OPTIONS
-d Toggle debugging of processing the configuration file. -n This flag (no-change) prevents ippool from actually making any ioctl calls or doing anything which would alter the currently running kernel. -v Turn verbose mode on. COMMAND OPTIONS
-a Add a new data node to an existing pool in the kernel. -A Add a new (empty) pool to the kernel. -f <file> Read in IP pool configuration information from the file and load it into the kernel. -F Flush loaded pools from the kernel. -l Display a list of pools currently loaded into the kernel. -r Remove an existing data node from a pool in the kernel. -R Remove an existing pool from within the kernel. -s Display IP pool statistical information. OPTIONS
-i <ipaddr>[/<netmask>] Sets the IP address for the operation being undertaken with an all-one's mask or, optionally, a specific netmask given in either the dotted-quad notation or a single integer. -m <name> Sets the pool name for the current operation. -M <core> Specify an alternative path to /dev/kmem to retrieve statistical information from. -N <namelist> Specify an alternative path to lookup symbol name information from when retrieving statistical information. -o <role> Sets the role with which this pool is to be used. Currently only ipf, auth and count are accepted as arguments to this option. -S <seed> Sets the hashing seed to the number specified. Only for use with hash type pools. -t <type> Sets the type of pool being defined. Myst be one of tree, hash, group-map. -u When parsing a configuration file, rather than load new pool data into the kernel, unload it. FILES
/dev/iplookup /etc/ippool.conf SEE ALSO
ippool(5), ipf(8), ipfstat(8) IPPOOL(8)
All times are GMT -4. The time now is 02:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy