It does the 'cat' cmd but then can't find the same file, which DOES exist...
MBAir3:batch Fred$ cat c.py
import os
host_name = os.system('hostname > ~/batch/fjhostname.txt')
print('cat of ~/batch/fjhostname.txt')
junk=os.system('cat ~/batch/fjhostname.txt')
with open("~/batch/fjhostname.txt", "r") as h:
for line in h:
fjhostname=line
junk = os.system('rm ~/batch/fjhostname.txt')
Result:
MBAir3:batch Fred$ python3 c.py
cat of ~/batch/fjhostname.txt
MBAir3
Traceback (most recent call last):
File "c.py", line 5, in <module>
with open("~/batch/fjhostname.txt", "r") as h:
FileNotFoundError: [Errno 2] No such file or directory: '~/batch/fjhostname.txt'
Files after run: (fjhostname.txt does exist in ~/batch)
MBAir3:batch Fred$ ls
B4 copy.py B4.py.FJSNAP1 B4doc06 aaa fjhostname.txt
B4.py B4.py.FJSNAP2 B4doc89 c.py git