Friday, August 14, 2020
dbametrix
More
    Home Technology A Simple Shell Script Example

    A Simple Shell Script Example

    A Simple Shell Script Example

    shell script exampleCombining various command options can lead to hideously complex commands. If you are loath to type such long-winded commands on a regular basis, Unix and Linux offer the shell script option, which merits a brief detour. Here is you can find out the simple practical approach of shell script. You can readily see ps command; say so that ps perform a complex command with less typing effect.

    Using ps command you can get a result of Oracle processes with the instance name.

    - Advertisement -
    dbametrix

    Ps –ef | grep smon| grep –v grep

    The output comes with all running smon processes of Oracle instances. If you create a file with name “trap_smon” or something else and write down these all commands in the same file. It is called a shell script because it contains all shell commands.

    Vi trap_smon

    Ps –ef|grep smon| grep –v grep

    - Advertisement -
    dbametrix

    After saving above trap_smon file, you can execute using command sh trap_smon and get the output of same at any time. You can schedule it too using crontab utility of Unix and Linux. If you don’t want to execute using “sh trap_smon” then you need to make it executable. After changing the permission of shell script, you can able to make it executable as following.

    Chmod +x trap_smon

    Trap_smon

    The u+x option in chmod gives you alone permission to execute, as the owner. If you want to grant all users permission to use trap_smon, you would vary the chmod option as follows

    Chmod a+x trap_smon

    Or

    Chmod +x trap_smon

    If you want to provide permission to your group only then you can use g+x with change permission command as following.

    Chmod g+x trap_smon

    After using chmod, you should run ls –l trap_smon to check that it has correct x fields for your purposes.

    Shell scripts are available for all shells like Bourne, Korne, C shells, although the syntax and available features are different. Peculiar to the C shell, though, is another keystroke-saving ploy called the alias command.

    2+
    - Advertisement -
    dbametrix
    - Advertisment -
    dbametrix

    Most Popular

    ORA-01940: Cannot drop a user that is currently connected

    Detail explanation and solution of ORA-01940: Cannot drop a user that is currently connected error.

    Ubuntu and Oracle SQL Developer

    Blog post explains how to install and use of Oracle SQL Developer on Ubuntu linux server

    Create Schema in Oracle 18c XE

    Article explain how to create new user in Oracle 18c XE and grant some system privileges with connect as new schema user in database.

    Oracle Autonomous JSON database

    The blog article explains about What is the Oracle autonomous JSON database, usage and how to get it from Oracle Cloud.

    Recent Comments

    Margareta Combes on nosql Security Vulnerabilities
    Gordon Coleclough on Oracle Tuning Basics Part-1
    Gordon Coleclough on ASM Disk creation issue