forked from hpreston/python_networking
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample1.py
More file actions
executable file
·42 lines (29 loc) · 1.09 KB
/
Copy pathexample1.py
File metadata and controls
executable file
·42 lines (29 loc) · 1.09 KB
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
#! /usr/bin/env python
"""Example Python script.
Copyright (c) 2018 Cisco and/or its affiliates."""
import os
def say_hello(name):
"""Function that will say hello to someone.
"""
# Print out a hello message to the name given
print("Hello there {name}. It's great to see you.".format(name = name))
def script_details():
"""Function that reports by printing to screen some details about the execution of the script."""
# Get the current directory and print it out.
cur_dir = os.getcwd()
print("Current directory is {}".format(cur_dir))
# Get the User ID and Group List for the User
user_id = os.getuid()
group_list = os.getgroups()
# Print to screen
print("The user id is {}".format(user_id))
print("The user is a member of the following groups:")
print(",".join(str(g) for g in group_list))
if __name__ == "__main__":
# If executed as a script, run this block.
# Check Script details
script_details()
# List of names, and say hello to them
names = ["Hank","Eric","Stuart","Bryan"]
for name in names:
say_hello(name)