Sponsored Content
Top Forums Programming Python Conditional Statements Based on Success of Last Command Post 302867701 by wisecracker on Thursday 24th of October 2013 06:11:24 PM
Old 10-24-2013
Be aware!
Code:
Last login: Thu Oct 24 23:06:01 on ttys000
AMIGA:barrywalker~> python3.3
Python 3.3.2 (v3.3.2:d047928ae3f6, May 13 2013, 13:52:24) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> retcode=os.system("claer")
sh: claer: command not found
>>> type(retcode)
<class 'int'>
>>> print(retcode)
32512
>>> retcode=os.system("ls /tmp")
0001d5269d380		launch-Tz0C4e		launchd-1575.z2293S
launch-KKNp3U		launch-hwShRg		text
launch-MSWbKw		launchd-124.mdpfPn
>>> type(retcode)
<class 'int'>
>>> print(retcode)
0
>>> _

This User Gave Thanks to wisecracker For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Conditional Statements

How can I compare two decimal values within a function using Bash? Function fun2 isn't comparing the decimal values. Is there a way to do this using Bash or Korn? #!/bin/bash set -x x=1 z=110 function fun1() { i=`bc << EOF 2>> /dev/null scale=3 ... (1 Reply)
Discussion started by: cstovall
1 Replies

2. UNIX for Dummies Questions & Answers

Success status of mailx command

Hi I want to know if the email address in the mailx exists or not Eg: Mailx -s "Subj" hello@ab.com How do I know if the email address is a valid one??? (4 Replies)
Discussion started by: superprogrammer
4 Replies

3. Shell Programming and Scripting

for i loop with conditional statements?

New to scripting in general, so patience plz. If I ask a stupid question or don't get it, I thank you for your kindness in advance. That said, did a for i loops checks to see if a PB* file is there but I need to know two things before I copy the file. I need to know if the file's create date... (2 Replies)
Discussion started by: xgringo
2 Replies

4. Programming

Conditional Compilation based on Environmental Variable in Unix

I want to be able to access an environment variable to control how a program is compiled. So: export MY_VERSN=9 Then ideally, within my C++ code, I would have #if MY_VERSN = 9 iret = FRED9() #else iret = FRED() #endif The way I thought I could do it is that in the script that... (2 Replies)
Discussion started by: BrighterLater
2 Replies

5. Shell Programming and Scripting

Python script - control flow statements

Hi guys.I'm just beginner of python. I'm just trying to do some analysis on simple input file. it has 6 columns and i want to consider k,l and m,n if i and j are + after that checking which value is greater or lower in k,l and m,n I have included logic header just to explain what I was... (4 Replies)
Discussion started by: repinementer
4 Replies

6. Shell Programming and Scripting

How to use awk or nawk by using Conditional Statements

Hi Guys! Anybody know how can I use a nawk or awk on a script and printing the NAME, SECTION (must be 410 or 411 or 414) and TOTAL COST of CLASS 1 and 3 combined must be greater than 50. See below desired output file. input.txt: NAME,CLASS,COST,SECTION JOHN,1,10,410 JOHN,2,20,410... (2 Replies)
Discussion started by: pinpe
2 Replies

7. UNIX for Dummies Questions & Answers

Conditional execution of statements

Hi , I have a script which has multiple awk and sed commands like below. First one :- find /root/src/ -name "*csv" -size 0 -exec rm {} \; Second one: - ls *SRE*.txt > SRT_TRAN.dat rm *asr*.txt Third one :- find /root/src/ -name '*.csv' | while read FILENAME ; do awk... (2 Replies)
Discussion started by: shruthidwh
2 Replies

8. UNIX for Dummies Questions & Answers

Check Success Status Of sed command

How do i check success status of a sed command execution i have the below script not sure if it is right approach to check status of execution using a function. Also it looks like in the below sed command even if the search string doesn't exist in the file it is returning status as success as i... (6 Replies)
Discussion started by: Ariean
6 Replies

9. Shell Programming and Scripting

Executes scripts parallelly based on their success

Hi Team , I have one Master.sh file which call X,Y,Z scripts , but here X may call again some sub scripts X_sub1.sh , X_sub2.sh Y calls Y_sub1.sh,Y_sub2.sh and similarly Z script also . Now requirement is Both X and Y should execute parallel bcz X and Y are independent... (9 Replies)
Discussion started by: chandini
9 Replies

10. Shell Programming and Scripting

Conditional deletion of files based on extension

Hello All, I have some files like file, file.chk, file.sem and file.temp in huge. I would like to delete some files based on following criteria. 1. Unconditionally delete .sem and .temp files 2. If we found the actual file, don't remove .chk file, otherwise remove .chk file as well for... (5 Replies)
Discussion started by: VasuKukkapalli
5 Replies
SLAPO-RETCODE(5)						File Formats Manual						  SLAPO-RETCODE(5)

NAME
slapo-retcode - return code overlay to slapd SYNOPSIS
/etc/ldap/slapd.conf DESCRIPTION
The retcode overlay to slapd(8) is useful to test the behavior of clients when server-generated erroneous and/or unusual responses occur, e.g. error codes, referrals, excessive response times and so on. The error responses are generated according to different strategies. In the first case, all operations targeted at a specific configurable subtree cause the object related to the request DN to be looked up and checked for return code data: a response code, plus an optional textual message, an optional configurable delay, an optional matched DN field, and, when the response code is "referral", a (list of) referral(s). Well-known response codes from standard track documents are provided in retcode.conf, which can be included after instantiating the over- lay. In the second case, objects of classes inherited from the errAbsObject, like errObject or errAuxObject, when returned as intermediate responses of a search request, are changed into the response dictated by their content. A third mode causes objects to be looked up from the underlying database to discover if their class inherits from errABsObject; in that case, their content is used to compute the corresponding response. The behavior is disabled by using the manageDSAit control (RFC 3296); in that case, the resulting object, either present in the directory or dynamically generated by the overlay, or contained in the request, is handled as usual. The config directives that are specific to the retcode overlay must be prefixed by retcode-, to avoid conflicts with directives specific to the underlying database or to other stacked overlays. The following specific directives can be used to configure the retcode overlay: retcode-parent <DN> This directive defines the parent DN where dynamically generated entries reside. If not defined, the suffix of the database is used. retcode-item <RDN> <errCode> [op=<oplist>] [text=<message>] [ref=<referral>] [sleeptime=<sec>] [matched=<DN>] [unsolicited=<OID>[:<data>]] [flags=[{pre|post}-]disconnect[,...]] A dynamically generated entry, located below retcode-parent. The errCode is the number of the response code; it can be in any format supported by strtol(3). The optional oplist is a list of operations that cause response code generation; if absent, all operations are affected. The matched field is the matched DN that is returned along with the error, while the text field is an optional diagnostics message. The ref field is only allowed for the referral response code. The sleeptime field causes slapd(8) to sleep the specified number of seconds before proceeding with the operation. The unsolicited field can be used to cause the return of an RFC 4511 unsolicited response message; if OID is not "0", an extended response is generated, with the optional data appended. If flags contains disconnect, or pre-disconnect, slapd(8) disconnects abruptly, without notice; post-disconnect causes disconnection right after sending response as appropriate. retcode-indir Enables exploitation of in-directory stored errAbsObject. May result in a lot of unnecessary overhead. retcode-sleep [-]<n> Defines a sleep time in seconds that is spent before actually handling any operation. If negative, a random time between 0 and the absolute value of the argument is used. SCHEMA
The retcode overlay utilizes the "return code" schema described herein. This schema is specifically designed for use with this overlay and is not intended to be used otherwise. It is also noted that the schema described here is a work in progress, and hence subject to change without notice. The schema is loaded automatically by the overlay. The schema includes a number of object classes and associated attribute types as described below. The error code: ( 1.3.6.1.4.1.4203.666.11.4.1.1 NAME ( 'errCode' ) DESC 'LDAP error code' EQUALITY integerMatch ORDERING integerOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) The operations that trigger the response code: ( 1.3.6.1.4.1.4203.666.11.4.1.2 NAME ( 'errOp' ) DESC 'Operations the errObject applies to' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) The text message: ( 1.3.6.1.4.1.4203.666.11.4.1.3 NAME ( 'errText' ) DESC 'LDAP error textual description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) The sleep time before the response is actually returned to the client: ( 1.3.6.1.4.1.4203.666.11.4.1.4 NAME ( 'errSleepTime' ) DESC 'Time to wait before returning the error' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) The matched DN returned to the client: ( 1.3.6.1.4.1.4203.666.11.4.1.5 NAME ( 'errMatchedDN' ) DESC 'Value to be returned as matched DN' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE ) The OID to be returned as extended response OID in RFC 4511 unsolicited responses ("0" generates a regular response with msgid set to 0): ( 1.3.6.1.4.1.4203.666.11.4.1.6 NAME ( 'errUnsolicitedOID' ) DESC 'OID to be returned within unsolicited response' EQUALITY objectIdentifierMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 SINGLE-VALUE ) The octet string to be returned as extended response data in RFC 4511 unsolicited response: ( 1.3.6.1.4.1.4203.666.11.4.1.7 NAME ( 'errUnsolicitedData' ) DESC 'Data to be returned within unsolicited response' SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE ) If TRUE, slapd(8) disconnects abruptly without notice; if FALSE, it disconnects after sending response as appropriate: ( 1.3.6.1.4.1.4203.666.11.4.1.8 NAME ( 'errDisconnect' ) DESC 'Disconnect without notice' SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE ) The abstract class that triggers the overlay: ( 1.3.6.1.4.1.4203.666.11.4.3.0 NAME ( 'errAbsObject' ) SUP top ABSTRACT MUST ( errCode ) MAY ( cn $ description $ errOp $ errText $ errSleepTime $ errMatchedDN ) ) The standalone structural objectclass for specifically created data: ( 1.3.6.1.4.1.4203.666.11.4.3.1 NAME ( 'errObject' ) SUP errAbsObject STRUCTURAL ) The auxiliary objectclass to alter the behavior of existing objects: ( 1.3.6.1.4.1.4203.666.11.4.3.2 NAME ( 'errAuxObject' ) SUP errAbsObject AUXILIARY ) EXAMPLE
overlay retcode retcode-parent "ou=RetCodes,dc=example,dc=com" # retcode.conf is found in tests/data/ of the source tree include ./retcode.conf # Wait 10 seconds, then return success (0x00) retcode-item "cn=Success after 10 seconds" 0x00 sleeptime=10 # Wait 10 seconds, then return timelimitExceeded (0x03) retcode-item "cn=Timelimit after 10 seconds" 0x03 sleeptime=10 FILES
/etc/ldap/slapd.conf default slapd configuration file SEE ALSO
slapd.conf(5), slapd-config(5), slapd(8). The slapo-retcode(5) overlay supports dynamic configuration via back-config. ACKNOWLEDGEMENTS
This module was written in 2005 by Pierangelo Masarati for SysNet s.n.c. OpenLDAP 2012/04/23 SLAPO-RETCODE(5)
All times are GMT -4. The time now is 02:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy