Home > FAQs > How do I use Python with RightScripts?

MindTouch
Copyright (c) 2006-2014 MindTouch Inc.
http://mindtouch.com

This file and accompanying files are licensed under the MindTouch Master Subscription Agreement (MSA).

At any time, you shall not, directly or indirectly: (i) sublicense, resell, rent, lease, distribute, market, commercialize or otherwise transfer rights or usage to: (a) the Software, (b) any modified version or derivative work of the Software created by you or for you, or (c) MindTouch Open Source (which includes all non-supported versions of MindTouch-developed software), for any purpose including timesharing or service bureau purposes; (ii) remove or alter any copyright, trademark or proprietary notice in the Software; (iii) transfer, use or export the Software in violation of any applicable laws or regulations of any government or governmental agency; (iv) use or run on any of your hardware, or have deployed for use, any production version of MindTouch Open Source; (v) use any of the Support Services, Error corrections, Updates or Upgrades, for the MindTouch Open Source software or for any Server for which Support Services are not then purchased as provided hereunder; or (vi) reverse engineer, decompile or modify any encrypted or encoded portion of the Software.

A complete copy of the MSA is available at http://www.mindtouch.com/msa

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

Glossary | 用語용어 Site Map | Site Help Community Corporate Site Get Support Dashboard Login
Doc Feedback Product Feedback Resources MultiCloud Marketplace Forums

Dashboard Status


© 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.