There's something to be said for both [[ ... ]] and && || and something against.
Personally I prefer [ ... ] and quotes where needed, and an if [ ... ]; then else where the && part could itself fail.
[[ ]] is testing the test, and leaves you not knowing necessarily why the inner test failed. Was the condition false? Was the variable not declared when it should have been?
I want to be able to run a script on one server, that will spawn another shell which runs some commands on another server..
I have seen some code that may help - but I cant get it working as below:
spawn /usr/bin/ksh
send "telnet x <port_no>\r"
expect "Enter command: "
send "LOGIN:x:x;... (2 Replies)
well i have this code here..and it works fine in kornshell..
#!/bin/ksh
home=c:/..../
input=$1
sed '1,3d' $input > $1.out
line=""
cat $1.out | while read a
do
line="$line $a"
done
echo $line > $1
rm $1.out
however...now i want it just in normal sh mode..how to convert this?... (21 Replies)
Hello,
I'm currently messing around with arrays for the first time in scripting (Unix Korn Shell). All I'm trying to do right now before I make things complicated is read through and print out to screen whether the read file is or is not a directory.
Here is my directory:
ls -l
total... (5 Replies)
Hi,
The logic is very simple but I can't seem to make this work in Korn shell.
I need to check two files to make sure there is no errors. Each of the file will have number. For example, first file btt.txt will have 112 which is good. Second file bgg.txt will have 6 which is also good. If I... (4 Replies)
Hi to everybody!
I want to write a simple script in ksh that decrypts and encrypts using the DES algorithm.
There is no builtin function in UNIX : i have found only a function in openssl but i don't understand how to use it.
The script must accept in input the plaitext and the DESKEY in... (2 Replies)
Hi All
I have writing a Korn Shell script to execute it on many of our servers. But some servers don't have Korn Shell installed, they use Borne Shell.
Some operations like calculation don't work :
cat ${file1} | tail -$((${num1}-${num2})) > ${file2}
Is it possible to activate Korn Shell... (3 Replies)
Could some one tell me the difference btw Bourne shell and the Kshell? Which is more flexible and reliable in terms of portability and efficiency. When i type the following command ..
$ echo $SHELL
yields me
/bin/sh
Does this tells me that I am in Bourne shell. If yes, how can i get... (6 Replies)
Hi I have the following Korn script having multiple for loops.
#!/bin/ksh
EXPECT=/usr/local/bin/expect
exp_internal
for d in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 i22 23 24 25 26; do
for i in 01 02 03 04 05 06 07 ; do
for h in 00 01 02 03 04 05 06 07 08 09 10 11 12... (2 Replies)
Hi i have to cut columns 2 to 6 from a file and assign it to arrays ,
The following code works
for ctcol in 2 3 4 5 6;
do
set -A a$ctcol $(cut -d, -f $ctcol test_file)
done
how ever this does not work
for ctcol in {2..6};
do
set -A a$ctcol $(cut -d, -f $ctcol test_file)... (4 Replies)
Hi,
I am facing an issue wherein some temporary files (here docs) are getting created in /tmp and are not getting deleted automatically.
When i check the list of open files with below command i can see one file is getting appended continuously.(In this case /tmp/sfe7h.34p)
The output is... (4 Replies)
Discussion started by: Navin_Ramdhami
4 Replies
LEARN ABOUT DEBIAN
py.test
PY.TEST(1) pytest PY.TEST(1)NAME
pytest - pytest usage
CALLING PY.TEST THROUGH PYTHON -M PY.TEST
New in version 2.0.
If you use Python-2.5 or later you can invoke testing through the Python interpreter from the command line:
python -m pytest [...]
This is equivalent to invoking the command line script py.test [...] directly.
GETTING HELP ON VERSION, OPTION NAMES, ENVIRONMENT VARIABLES
py.test --version # shows where pytest was imported from
py.test --funcargs # show available builtin function arguments
py.test -h | --help # show help on command line and config file options
STOPPING AFTER THE FIRST (OR N) FAILURES
To stop the testing process after the first (N) failures:
py.test -x # stop after first failure
py.test --maxfail=2 # stop after two failures
SPECIFYING TESTS / SELECTING TESTS
Several test run options:
py.test test_mod.py # run tests in module
py.test somepath # run all tests below path
py.test -k string # only run tests whose names contain a string
Import 'pkg' and use its filesystem location to find and run tests:
py.test --pyargs pkg # run all tests found below directory of pypkg
MODIFYING PYTHON TRACEBACK PRINTING
Examples for modifying traceback printing:
py.test --showlocals # show local variables in tracebacks
py.test -l # show local variables (shortcut)
py.test --tb=long # the default informative traceback formatting
py.test --tb=native # the Python standard library formatting
py.test --tb=short # a shorter traceback format
py.test --tb=line # only one line per failure
DROPPING TO PDB (PYTHON DEBUGGER) ON FAILURES
Python comes with a builtin Python debugger called PDB. py.test allows one to drop into the PDB prompt via a command line option:
py.test --pdb
This will invoke the Python debugger on every failure. Often you might only want to do this for the first failing test to understand a
certain failure situation:
py.test -x --pdb # drop to PDB on first failure, then end test session
py.test --pdb --maxfail=3 # drop to PDB for the first three failures
SETTING A BREAKPOINT / AKA SET_TRACE()
If you want to set a breakpoint and enter the pdb.set_trace() you can use a helper:
import pytest
def test_function():
...
pytest.set_trace() # invoke PDB debugger and tracing
In previous versions you could only enter PDB tracing if you disabled capturing on the command line via py.test -s.
PROFILING TEST EXECUTION DURATION
To get a list of the slowest 10 test durations:
py.test --durations=10
CREATING JUNITXML FORMAT FILES
To create result files which can be read by Hudson or other Continuous integration servers, use this invocation:
py.test --junitxml=path
to create an XML file at path.
CREATING RESULTLOG FORMAT FILES
To create plain-text machine-readable result files you can issue:
py.test --resultlog=path
and look at the content at the path location. Such files are used e.g. by the PyPy-test web page to show test results over several revi-
sions.
SENDING TEST REPORT TO POCOO PASTEBIN SERVICE
Creating a URL for each test failure:
py.test --pastebin=failed
This will submit test run information to a remote Paste service and provide a URL for each failure. You may select tests as usual or add
for example -x if you only want to send one particular failure.
Creating a URL for a whole test session log:
py.test --pastebin=all
Currently only pasting to the http://paste.pocoo.org service is implemented.
CALLING PY.TEST FROM PYTHON CODE
New in version 2.0.
You can invoke py.test from Python code directly:
pytest.main()
this acts as if you would call "py.test" from the command line. It will not raise SystemExit but return the exitcode instead. You can
pass in options and arguments:
pytest.main(['x', 'mytestdir'])
or pass in a string:
pytest.main("-x mytestdir")
You can specify additional plugins to pytest.main:
# content of myinvoke.py
import pytest
class MyPlugin:
def pytest_addoption(self, parser):
raise pytest.UsageError("hi from our plugin")
pytest.main(plugins=[MyPlugin()])
Running it will exit quickly:
$ python myinvoke.py
ERROR: hi from our plugin
AUTHOR
holger krekel at merlinux eu
COPYRIGHT
2011, holger krekel et alii
2.2 June 24, 2012 PY.TEST(1)