-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpyshell.sh
More file actions
executable file
·46 lines (35 loc) · 784 Bytes
/
Copy pathpyshell.sh
File metadata and controls
executable file
·46 lines (35 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
SCRIPT=""" "
#echo $*
#echo $0
########## BEGIN BASH SCRIPT ##########
# add your code here
func1() {
echo "hello"
}
########## END BASH SCRIPT ##########
if [[ $0 == bash ]]; then
return 0
fi
exec python -E $0 "$@"
SCRIPT=" """
#!/usr/bin/python
import sys
import os
def invokeBash(cmdline):
#args = 'bash -c "source %s;%s #__INVOKE__;"' % (sys.argv[0], cmdline)
args = 'bash -c "source %s;%s;"' % (sys.argv[0], cmdline)
#print args
pipe = os.popen(args);
#return os.system(args)
return pipe.read()
########## BEGIN PYTHON SCRIPT ##########
# add your code here
import re
#print 'Hello'
#for i in range(1,5):
# print i
print invokeBash('func1')
print invokeBash('ls')
print 'uname -a:\t', invokeBash('uname -a')
########## END PYTHON SCRIPT ##########