plumbum icon indicating copy to clipboard operation
plumbum copied to clipboard

Commands work in the shell, but not Plumbum

Open charlie-ht opened this issue 7 years ago • 2 comments

My command looks like this,

echo[partition_map] | sudo[sfdisk[self.device_path]]

Printing the command looks like

/usr/bin/echo '
label: dos
label-id: 0x7f93fbc8
device: /dev/sdc
unit: sectors

/dev/sdc1 : start=        2048, size=      614400, type=c
/dev/sdc2 : start=      616448, size=    30499840, type=83
' | /usr/bin/sudo /usr/sbin/sfdisk /dev/sdc

If I copy and paste that command into my shell, I get an exit code of zero and successful messages. If I run the Plumbum command, I get a uninformative error message, and then a stdout report that it cut off right before the first line of stderr from sfdisk. I have no idea where the exit status of -13 came from.

plumbum.commands.processes.ProcessExecutionError: Command line: ['/usr/bin/sudo', '/usr/sbin/sfdisk', '/dev/sdc']
Exit code: -13
Stdout:  | Checking that no-one is using this disk right now ... OK
         | 
         | Disk /dev/sdc: 14.9 GiB, 15931539456 bytes, 31116288 sectors
         | Units: sectors of 1 * 512 = 512 bytes
         | Sector size (logical/physical): 512 bytes / 512 bytes
         | I/O size (minimum/optimal): 512 bytes / 512 bytes
         | Disklabel type: dos
         | Disk identifier: 0x7f93fbc8
         | 
         | Old situation:
         | 
         | Device     Boot  Start      End  Sectors  Size Id Type
         | /dev/sdc1         2048   616447   614400  300M  c W95 FAT32 (LBA)
         | /dev/sdc2       616448 31116287 30499840 14.6G 83 Linux
         | 
         | >>> Script header accepted.
         | >>> Script header accepted.
         | >>> Script header accepted.
         | >>> Script header accepted.
         | >>> Created a new DOS disklabel with disk identifier 0x7f93fbc8.
         | /dev/sdc1: Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 300 MiB.

What's going on, how can the command Plumbum reports it's about to run fail to run, yet works in the shell?

charlie-ht avatar Aug 12 '17 18:08 charlie-ht

Alright, if I change the command to sudo [echo[partition_map] | sfdisk[self.device_path]] it works. That's not intuitive to me :(

charlie-ht avatar Aug 12 '17 18:08 charlie-ht

You can drop echo part and use < semantic

sudo[sfdisk[self.device_path]] < partition_map

asmfreak avatar Sep 14 '17 10:09 asmfreak