Note: Please go to docs.rightscale.com to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > FAQs > How do I use Python with RightScripts?

How do I use Python with RightScripts?

Table of Contents

Background Information

Currently, a majority of the Linux RightScripts in the MultiCloud Marketplace use Bash and Ruby. However, you can use almost any scripting language as long as the interpreter is installed and you define the inputs 'like variables' in comments at the beginning of your script. Defining your script this way gives you the benefits of our version control, change auditing, and the ability to attach files to accompany the script.

 


Answer

1.  Create a New RightScript.  Write a script in your preferred language (Python is used in the example below), defining one input via a comment.  Then, use the language-specific method to retrieve regular environment variables:

#!/usr/bin/python
#
# Inputs:
# $TEST_PARAM

import os

# Print the input to the audit entries
print os.environ['TEST_PARAM']

2. Use the "Identify" button to identify the inputs defined in the script comments. Save the script.

Picture 38.png

 

3. You are now ready to run the RightScript and observe its results under the Audit Entries tab. ("Hello Python World" was used as the TEST_PARAM in the example below.)

You must to post a comment.
Last modified
21:26, 16 May 2013

Tags

Classifications

This page has no classifications.

Announcements

None


© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.