Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
file handling
#1
import os, sys
from subprocess import Popen,PIPE
myfs=input("myfs=")
try:
#grep myfs /etc/fstab
  p1 = Popen(['grep',myfs,'/etc/fstab'], stdout=PIPE)
  p1.communicate()[0].decode('utf-8').split()[1]
  p1.stdout.close()
except IndexError:
  with open("/etc/fstab", "a+") as f:
      f.write(`df -h|grep myfs|awk '{print $1,$6}'` + ext4 + defaults + 1 + 2)
      f.close()
------------------------
i am getting an error like this
Error:
[root@localhost mylvm]# python test9.py File "test9.py", line 11 f.write(`df -h|grep myfs|awk '{print $1,$6}'` + ext4 + defaults + 1 + 2) ^ SyntaxError: invalid syntax
i need to update like this in /etc/fstab

/dev/mapper/vgdata-lvmyfssiva /myfs/siva ext4 defaults 1 2
Reply


Messages In This Thread
file handling - by sivareddy - Feb-23-2020, 02:02 PM
RE: file handling - by jefsummers - Feb-23-2020, 07:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  File Handling not working properly TheLummen 8 3,666 Feb-17-2024, 07:47 PM
Last Post: TheLummen
  file handling Newbee question middlecope 2 1,599 Jan-18-2023, 03:09 PM
Last Post: middlecope
Star python exception handling handling .... with traceback mg24 3 3,410 Nov-09-2022, 07:29 PM
Last Post: Gribouillis
  File handling issue GiggsB 4 2,505 Mar-31-2022, 09:35 PM
Last Post: GiggsB
  How can I solve this file handling issue? GiggsB 17 6,229 Feb-14-2022, 04:37 AM
Last Post: GiggsB
  How to solve this file handling issue? GiggsB 3 2,484 Jan-10-2022, 09:36 AM
Last Post: Gribouillis
  File handling knollfinder 3 2,724 Jun-28-2020, 07:39 PM
Last Post: knollfinder
  delete file with handling 3Pinter 1 2,629 Oct-17-2019, 04:06 PM
Last Post: 3Pinter
  Help with file handling gonzo620 10 10,743 Sep-27-2018, 06:28 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020