if executing a file, add the file's directory to the path to so that other files...
[plcapi.git] / plcsh
diff --git a/plcsh b/plcsh
index 936b943..9997c15 100755 (executable)
--- a/plcsh
+++ b/plcsh
@@ -5,7 +5,7 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2005 The Trustees of Princeton University
 #
-# $Id: plcsh,v 1.4 2007/01/17 22:14:38 mlhuang Exp $
+# $Id$
 #
 
 import os
@@ -22,6 +22,7 @@ parser = OptionParser(add_help_option = False)
 parser.add_option("-f", "--config", help = "PLC configuration file")
 parser.add_option("-h", "--url", help = "API URL")
 parser.add_option("-c", "--cacert", help = "API SSL certificate")
+parser.add_option("-k", "--insecure", help = "Do not check SSL certificate")
 parser.add_option("-m", "--method", help = "API authentication method")
 parser.add_option("-s", "--session", help = "API session key")
 parser.add_option("-u", "--user", help = "API user name")
@@ -58,10 +59,16 @@ except Exception, err:
     parser.print_help()
     sys.exit(1)
 
-# If called by a script
+# If called by a script 
 if len(sys.argv) > 1 and os.path.exists(sys.argv[1]):
     # Pop us off the argument stack
     sys.argv.pop(0)
+    script = sys.argv[0]
+    # Add of script to sys.path 
+    path = os.path.dirname(os.path.abspath(script))
+    sys.path.append(path)
+    from pprint import pprint
+    pprint(sys.path)                   
     execfile(sys.argv[0])
 
 # Otherwise, run an interactive shell environment