Tags:
create new tag
view all tags
---+ "Shebang" lines for scripts on Patas Here are the proper script headers for various interpreted languages on patas. ---++ Bash =#!/bin/bash= ---++ Perl v5.22.1 =#!/usr/local/bin/perl= (Note: The distribution perl at /usr/bin/perl does not have the linguistics-specific modules installed.) ---++ Python 2.6.x =#!/opt/python-2.6/bin/python2.6= ---++ Python 2.7 =#!/opt/python-2.7/bin/python2.7= ---++ Python 3.4 #!/opt/python-3.4/bin/python3.4 ---++ Ruby 1.8.7 =#!/usr/bin/ruby= ---++ Ruby 1.9.x =#!/opt/ruby-1.9/bin/ruby= ---++ Portable Shebang When developing scripts in other environments with final testing (and submission of homework) on patas, you may find that your development environment has the desired script binary in one place, and patas has the script binary in another. For example, you need to manually edit the shebang line on your perl scripts every time you move the perl script to patas. One way to get around this is to use _/usr/bin/env_ to find the path for your target script program, in this case perl. For example, you may see the following for the location of perl 5.10 on patas and your devel machine: <verbatim style="padding-left: 60px;"> patas: /opt/perl/bin/perl jscott42@patas:~$ which perl /opt/perl/bin/perl jscott42@patas:~$ perl --version This is perl, v5.10.0 built for x86_64-linux mymachine (hani-winxp): /usr/bin/perl jeffry@hani-winxp ~ $ which perl /usr/bin/perl jeffry@hani-winxp ~ $ perl --version This is perl, v5.10. (*) built for i686-cygwin-thread-multi-64int (with 12 registered patches, see perl -V for more detail) </verbatim> Replace your shebang line in your perl scripts to read: <verbatim style="padding-left: 60px;">#!/usr/bin/env perl</verbatim> and the local path for perl will automatically be substituted. *Important:* If you use this technique with Condor, you *must* include =getenv = true= in your Condor submit script; otherwise there won't be a valid _PATH_ variable for /usr/bin/env to work with. NB: to make sure you are using the same version of perl in both environments, run _which perl_ on each. If your devel version of perl doesn't match the version on patas, fiddle with your <em>PATH </em>environment variable so the proper version is found, or create a link in your local _/bin_, _/usr/bin_, or _/usr/local/bin_ to the proper version of perl on your devel machine. Use of */usr/bin/env* is a Good Thing in shebang lines, as it eliminates a lot of manual changes when doing cross-platform script development. And yes Virginia, it will work fine for python and ruby as well.
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r13
<
r12
<
r11
<
r10
<
r9
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r13 - 2016-04-11
-
brodbd
Home
Site map
Main web
Sandbox web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
E
dit
A
ttach
Copyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback