shebang

Bash shebang option -l

时光毁灭记忆、已成空白 提交于 2019-12-06 17:14:19
问题 I use a script, test.sh , written by someone else, the begins with a bash shebang: #!/bin/bash -l ... echo TEST: $TEST From what I could see, this has an effect on variables used inside the script: if I run TEST=hey ./test.sh , I can see TEST: hop , hop being the value of variable TEST in my .bash_profile this is the same if I export TEST=hey before running the script but if I remove the -l flag, the same command returns TEST: hey , as I would have expected Can someone please explain this

Passing Ruby interpreter arguments with hashbang command

走远了吗. 提交于 2019-12-06 12:45:00
I am using the following hashbang command with my RVM installation. How do I pass the -w argument to the ruby interpreter? #!/usr/bin/env ruby Thanks. I recommend setting the RUBYOPT environment variable. In this manner, you don't have to edit your executables. RUBYOPT="-w $RUBYOPT" According to this reference you can use a separate declaration outside of the shebang for that: #! /usr/bin/env ruby $VERBOSE=true 来源: https://stackoverflow.com/questions/17460206/passing-ruby-interpreter-arguments-with-hashbang-command

Relative shebang: How to write an executable script running portable interpreter which comes with it

这一生的挚爱 提交于 2019-12-06 05:40:05
问题 Let's say we have a program/package which comes along with its own interpreter and a set of scripts which should invoke it on their execution (using shebang). And let's say we want to keep it portable, so it remains functioning even if simply copied to a different location (different machines) without invoking setup/install or modifying environment (PATH). A system interpreter should not be mixed in for these scripts. The given constraints exclude both known approaches like shebang with

/usr/bin/env questions regarding shebang line pecularities

我只是一个虾纸丫 提交于 2019-12-06 01:38:49
问题 Questions : What does the kernel do if you stick a shell-script into the shebang line? How does the Kernel know which interpreter to launch? Explanation : I recently wanted to write a wrapper around /usr/bin/env because my CGI Environment does not allow me to set the PATH variable, except globally (which of course sucks!). So I thought, "OK. Let's set PREPENDPATH and set PATH in a wrapper around env.". The resulting script (here called env.1 ) looked like this: #!/bin/bash /usr/bin/env PATH=

Is there a standard way to make sure a python script will be interpreted by python3 and not python2?

无人久伴 提交于 2019-12-05 01:57:54
问题 Related: Is there a standard way to make sure a python script will be interpreted by python2 and not python3? Apparently not all distros ship with a python3 symlink, either. #!/usr/bin/env python3 causes a no-such-file-or-directory error. What shebang line should I use if my script requires any version of Python 3? 回答1: import sys try: assert sys.version_info[0] == 3 except: print "ERROR NOT PYTHON 3!" sys.exit() 来源: https://stackoverflow.com/questions/19625768/is-there-a-standard-way-to-make

How to add shebang #! with php script on linux?

孤街醉人 提交于 2019-12-04 23:49:46
I'm having a little issue with adding shebang #! with my php script on RedHat linux. I have a small piece of test code with shebang added (I've tried different variations as well), but I get the following error message everytime I try to run the script. Error msg: -bash: script.php: command not found Test script: #!/bin/env php <?php echo "test"; ?> Shebang #! variations: #!/usr/bin/php #!/usr/bin/env php It should (for most systems) be #!/usr/bin/env php , but your error isn't related to that. -bash: script.php: command not found It says that script.php is not found. If the problem was the

Bash shebang option -l

落花浮王杯 提交于 2019-12-04 22:59:44
I use a script, test.sh , written by someone else, the begins with a bash shebang: #!/bin/bash -l ... echo TEST: $TEST From what I could see, this has an effect on variables used inside the script: if I run TEST=hey ./test.sh , I can see TEST: hop , hop being the value of variable TEST in my .bash_profile this is the same if I export TEST=hey before running the script but if I remove the -l flag, the same command returns TEST: hey , as I would have expected Can someone please explain this behaviour ? The help of bash did not... help. dg99 The -l option (according to the man page ) makes "bash

how to make a python or perl script portable to both linux and windows?

风格不统一 提交于 2019-12-04 17:45:44
问题 I was wondering how to make a python script portable to both linux and windows? One problem I see is shebang. How to write the shebang so that the script can be run on both windows and linux? Are there other problems besides shebang that I should know? Is the solution same for perl script? Thanks and regards! 回答1: Windows will just ignore the shebang (which is, after all, a comment); in Windows you need to associate the .py extension to the Python executable in the registry, but you can

Git pre-commit hook not working on windows

穿精又带淫゛_ 提交于 2019-12-04 17:28:30
I have a git pre-commit hook, but after commiting to the local repo, the script does not get called. This is how it looks, it is in python, the name of the hook file is called pre-commit without any extension: #!C:/Users/al/AppData/Local/Programs/Python/Python35-32 python import sys, os sys.exit(1) Ashutosh Jindal Your pre-commit hook might suffer from one or more of the following issues: Is the shebang line correct? The shebang line should be the complete path to the executable which is used to run the script. See this to find out when the shebang line is used (or not-used). In the case of

Shebang for compiled Python code

假装没事ソ 提交于 2019-12-04 15:02:42
I used to add shebang line at top of Python script as, #!/usr/bin/python ... And I can execute the my.py file by, chmod a+r my.py ./my.py But after compiled to bytecode, the script can only be executed by python and the shebang does not work anymore. python my.pyc Is there anyway to make shebang workable to compiled python script? ./my.pyc Shebang works only for text scripts, not binary files. Nevertheless, you can use binfmt_misc to execute *.pyc files directly, as reported in this Python ML thread : Linux, you can use binfmt_misc to make executables out of pyc code. Run: import imp,sys