sys.argv index out of range error
Brian McCann
Brian.McCann at viziant.net
Thu Sep 13 15:16:50 EDT 2007
Hi,
I trying to create a bootstrap.sh shell script that takes two command line args that passes them
to two scripts. one script is init.sh that sets up some environment varilables
the other will be a Python script used as the main build script. the contents of the bootstrap file and init.sh are
I've simplified the scripts as much as I could and still retain the errors
bootstrap.sh
#!/bin/sh
cd /home/workspaces
export LANG="en_US.UTF-8"
source init $1
test.py $2
#################################
init.sh
#!/bin/sh
WORKSPACE_ROOT="$1";
export JAVA_OPTIONS="-Djava.library.path=$WORKSPACE_ROOT/:$WORKSPACE_ROOT/:$WORKSPACE_ROOT/"
echo "JAVA_OPTIONS="$JAVA_OPTIONS;
set PATH="$WORKSPACE_ROOT/vendor/basistech/rlp5.4/rlp/bin/ia32-glibc23-gcc32:$WORKSPACE_ROOT/vendor/basistech/rlp5.4/rlp/bin/ia32-w32-msvc71:$WORKSPACE_ROOT/lib/core:$PATH"
##############################################################################
when I run the bootstrap.sh with two args
$ ./bootstrap.sh spam ham
init takes the spam with no problem
this is the output on the command line
$ ./bootstrap.sh spam ham
JAVA_OPTIONS=-Djava.library.path=spam/:spam/:spam/
Traceback (most recent call last):
File "./test.py", line 12, in ?
aaa = sys.argv[1]
IndexError: list index out of range
This is the test.py script that gets the second arg
######################################
!/usr/bin/python
import string
import os
import sys
filename = sys.argv[0]
aaa = sys.argv[1]
print aaa
#################################
If I remove "source init $1" from init.sh and replace it with "init 1$" I get this output which works
$ bootstrap.sh spam ham
JAVA_OPTIONS=-Djava.library.path=spam/:spam/:spam/
ham
what's wrong with the line "source init $1 ?
Thanks,
Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070913/53dfcf3c/attachment.html>
More information about the Python-list
mailing list