Last active
July 19, 2016 17:57
-
-
Save davidnuon/ca82207972f2e45717406712ae0881ed to your computer and use it in GitHub Desktop.
Shebangs in Action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
print('Arguments') | |
print(sys.argv) | |
print('File content') | |
with open(sys.argv[-1]) as f: | |
print f.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./script | |
Arguments | |
['/home/davidnuon/davidbasic/basic', './script'] | |
File content | |
#!/home/davidnuon/davidbasic/basic | |
# ^ There can be anywhere | |
Here is my thing | |
WOLOLO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/home/davidnuon/davidbasic/basic | |
# ^ There can be anywhere | |
Here is my thing | |
WOLOLO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Interesting. On line 4 of output its it calling script as a variable?