Python Forum
[SOLVED]passing a lot of information to subprocess.call()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED]passing a lot of information to subprocess.call()
#2
This is all running under python 3.5.2
Well after a lot more googling I have found a different approach instead of subprocess.call
cat = subprocess.Popen(['cat', '/home/norman/khconf/second.txt'], 
                        stdout=subprocess.PIPE,
                        )

sort = subprocess.Popen(['sort'],
                        stdin=cat.stdout,
                        stdout=subprocess.PIPE,
                        )

uniq = subprocess.Popen(['uniq'],
                        stdin=sort.stdout,
                        stdout=subprocess.PIPE,
                        )


end_of_pipe = uniq.stdout
lastfile = docs + "/third.txt"

lastone = open(lastfile, 'w')
lastone.write("Hello World")
for line in end_of_pipe:
    lastone.write(line)
I get no errors but third.txt only contains the "Hello World"
I modified the code from https://pymotw.com/2/subprocess/
Can anyone suggest how I can fix this please?
Reply


Messages In This Thread
RE: passing a lot of information to subprocess.call() - by Barrowman - Jan-26-2018, 09:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  continue if 'subprocess.call' failes tester_V 11 5,443 Aug-26-2021, 12:16 AM
Last Post: tester_V
  printing out the contents aftre subprocess.call() Rakshan 3 2,869 Jul-30-2021, 08:27 AM
Last Post: DeaD_EyE
  subprocess call cannot find the file specified RRR 6 17,027 Oct-15-2020, 11:29 AM
Last Post: RRR
  Why wont subprocess call work? steve_shambles 3 2,765 Apr-28-2020, 03:06 PM
Last Post: steve_shambles
  subprocess.call - Help ! sniper6 0 1,565 Nov-27-2019, 07:42 PM
Last Post: sniper6
  Mock call to subprocess.Popen failing with StopIteration tharpa 7 6,064 Nov-08-2019, 05:00 PM
Last Post: Gribouillis
  Echo call to VLC bash using subprocess.Popen on Linux LuukS001 17 9,930 Jan-07-2019, 03:58 AM
Last Post: LuukS001
  Why is subprocess.call command not working? zBernie 5 10,879 Nov-19-2018, 11:11 PM
Last Post: snippsat
  Help with subprocess..call oldcity 1 2,615 Sep-28-2018, 03:59 PM
Last Post: volcano63
  subprocess.call salmaankamil 1 2,774 Jul-27-2018, 06:50 PM
Last Post: woooee

Forum Jump:

User Panel Messages

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