Sponsored Content
Top Forums Shell Programming and Scripting Making a KSH exit if path is not correct Post 302339353 by jim mcnamara on Thursday 30th of July 2009 09:50:32 AM
Old 07-30-2009
Code:
if [[ ! -d /opt/$1/Agent ]] ; then
  echo "bad parameter: directory /opt/$1/Agent not found."
  exit 1
fi

Is that what you need?
 

10 More Discussions You Might Find Interesting

1. Programming

Exit Code in HP-UX KSH.

In one of my programs another process is called using the system command e.g. lv_error = system("myproc"); where lv_error is declared as an int. myproc would be returning 0 for success and 1 for failure. e.g. if (success) { return(0); }else{ return(1); } When the return code... (3 Replies)
Discussion started by: mbb
3 Replies

2. UNIX for Advanced & Expert Users

How to exit the KSH functions

Hi I am having the script which contains more functions. I want to exit the function if any failure. I tried with exit - the session itself is getting logged out. How can i fix this issue? (11 Replies)
Discussion started by: sharif
11 Replies

3. Solaris

Correct me to run a sh file in ksh shell!

Hi all! I wrote a file named as rman_backup.sh, and this is contents #!/bin/ksh ORACLE_SID=VNP;export ORACLE_SID echo $ORACLE_SID echo "Please Specify the kind of backup you want to take" echo "1) LEVEL 0 VNP" echo "2) LEVEL 1 VNP" echo "3) EXPORT BACKUP" echo "Enter your option" ... (4 Replies)
Discussion started by: trantuananh24hg
4 Replies

4. UNIX for Dummies Questions & Answers

Cannot retreive correct $PATH using PLINK

Hi, I'm using plink to execute shell script on UNIX machines. It works pretty well excepted with some machines where I don't have the same $PATH than with putty. I'm using the command PLINK.EXE -ssh machinename -l user -pw password echo $PATHAnd for putty nothing special set, I use ssh as... (2 Replies)
Discussion started by: Peuj
2 Replies

5. Shell Programming and Scripting

KSH: Test telnet and exit

Hi, I need to do a test Telnet in KSH and if the connection is good then disconnect the telnet session with out logging in and without exiting the shell script. Example output of a good connection: $telnet xxx.xx.xx.xxx xxxx Trying xxx.xx.xx.xxx... Connected to xxx.xx.xx.xxx. Escape... (1 Reply)
Discussion started by: calex
1 Replies

6. Shell Programming and Scripting

Terminal is closing on exit in ksh

hi while executing the following script, my terminal window is getting closed if I enter a invalid option. I want the script should go back the the command prompt. how to do achive it. i execute the script as . ./test #! /usr/bin/ksh Printf " Type of Installer : \n\t\t 1. Whole Build... (3 Replies)
Discussion started by: vij_krr
3 Replies

7. Shell Programming and Scripting

Exit if date not in correct format

Can somone take a look at this script for me - I'm trying to get it to exit if the format of dateToLookFor is not in the format YYYYMMDD: function search { cd $logsloc echo "Enter date in format YYYYMMDD (enter to exit):" read dateToLookFor echo $dateToLookFor | grep -q ... (2 Replies)
Discussion started by: rich@ardz
2 Replies

8. Shell Programming and Scripting

KSH: Confused with behaviour of exit

Hi Everyone, I am confused on why the below snippet of code is not working as I intend it to do. I have googled and confirmed that "exit" is supposed to abort the execution of the script regardless if the exit was called from inside a function, or the main body of the script. log_and_die() { ... (3 Replies)
Discussion started by: maddmaster
3 Replies

9. UNIX for Dummies Questions & Answers

Getting correct path to run appropriate script

I have tcsh scripts on path /home/chrisd/tatsh/trunk/hstmy/bin/tcsh/ I want to run the script from within another script. Suppose I go to directory /home/chrisd/tatsh/trunk/hsdata/n02/terr0.25/darwin and want to run checksrdist.tcsh So I do cd ... (1 Reply)
Discussion started by: kristinu
1 Replies

10. Shell Programming and Scripting

Send correct exit code from child script back to parent

Hello all; hope someone can help me cause I am going crazy trying to find a solution for (what I think is simple) issue...looked hard up and down this forum and tried several "solutions" with no avail...so here's my issue: I have this (parent) script: copylsofdcmcadefttosftpwithmove.sh ... (3 Replies)
Discussion started by: gvolpini
3 Replies
snmpext(3n)															       snmpext(3n)

Name
       snmpextregister,  snmpextgetreq,  snmpextrespond,  snmpexterror	-  library  routines available for building the Extended ULTRIX SNMP Agent
       (Extended Agent)

Syntax
       #include <protocols/snmp.h>
       #include <protocols/snmperrs.h>

       struct objident {
	    short     ncmp;	     /* number of components */
	    unsigned long	     cmp[SNMPMXID];/* components */
       };

       struct snmpareg {
	    short     oidtype;	     /* object id type */
	    objident  oid;	     /* object id/*
       };

       struct snmparspdat {
	    short     type;	     /* response data type */
	    short     octets;	     /* number of octets in response data */
	    char      *rspdat;	     /* response data */
       };

       snmpextregister(reg, community)
       struct snmpareg *reg;
       char *community;

       snmpextgetreq(reqoid, reqinst)
       objident *reqoid;
       objident *reqinst;

       snmpextrespond(reqoid, rspinst, rspdat)
       objident *reqoid;
       objident *rspinst;
       struct snmparspdat *rspdat;

       snmpexterror(error)
       long error;

Description
       The following library routines are available for building the Extended Agent:

       snmpextregister
	    Used to register the Extended Agent's Management Information Base (MIB) to the ULTRIX SNMP Agent (Agent).  The reg parameter  is  pro-
	    vided by the caller with the object identifiers to be registered. The community parameter is provided by the caller with the community
	    name (a null-terminated string).

	    This library routine waits for a registration confirmation from the Agent.	The process is blocked	until  the  confirmation  arrives.
	    When the confirmation arrives, the routine returns the status of the registration.

	    The  program  issues  this call before any other Extended SNMP Library calls.  It does this because the library routine creates a UNIX
	    domain socket to the Agent on behalf of the caller.

       snmpextgetreq
	    Used to receive a request for a MIB variable from the Agent.  If there is no outstanding  request  from  the  Agent,  the  process	is
	    blocked until a request arrives from the Agent.

	    When the Extended Agent receives a request from the Agent, the reqoid parameter contains the object identifier for the requested vari-
	    able.  The reqinst parameter contains the object instance identifier for the requested variable.  If the request does not contains	an
	    object instance, the reqinst->ncmp record contains a zero.

       snmpextrespond
	    Used  to return the requested variable to the Agent.  The reqoid parameter is the object identifier from the library call. The rspinst
	    parameter is the object instance associated with the returning variable.  If there is no object instance associated with the returning
	    variable, a null parameter must be supplied.  The rspdat parameter is the returning variable.

	    Note that the Agent maintains a configurable timer for outstanding requests to the Extended Agent.	Therefore, the Extended Agent must
	    be able to respond within the Agent's timeout interval in order to prevent a premature timeout in the Agent.

	    See the file for your system's default timeout value.

       snmpexterror
	    Used to return an error to the Agent.  The error parameter is the error code to be returned to the Agent.  The error code  is  one	of
	    the following:

	    NOERR--successful SNMP get-next-request end-of-table.  This happens when the requested instance does not exist.

	    NOSUCH--Unknown requested object identifier.

	    GENERRS--Generic error.

	    BADVAL--Bad variable value.

Restrictions
       For the routine, the object identifier must have the prefix 1.3.6.1 to be registered.  If it does not, the registration is rejected.

Return Values
       If an error occurs, a negative value is returned.

Diagnostics
       [BADVERSION]   Bad or obsolete protocol version

       [BINDERR]      Failed to bind the socket

       [GENSUC]       MIB successfully registered

       [NOSOCK]       Socket does not exist

       [NOSVC]	      MIB registration was rejected

       [PKTLENERR]    Maximum size message exceeded or community name is too large

       [RCV_ERR]      Reception failed

       [SND_ERR]      Transmission failed

Files
       SNMP configuration file

See Also
       snmpd.conf(5n), snmpd(8n), snmpsetup(8n)
       Guide to Network Programming

																       snmpext(3n)
All times are GMT -4. The time now is 04:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy