bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24215: command=`rm`: how to script responses?


From: Tom Roche
Subject: bug#24215: command=`rm`: how to script responses?
Date: Fri, 12 Aug 2016 16:21:12 -0700
User-agent: GNU Emacs 24.4.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.5)

[footnotes after .sig]

I am learning how to script `parted`, successfully insofar as the following 
scriptlet WFM[1]:

    ORIG_DRIVE_LABEL='D078BBB478BB97A4'
    ORIG_DRIVE_MOUNTPATH="/media/$(whoami)/${ORIG_DRIVE_LABEL}"
    DRIVE_DEV='/dev/sdb'

    date
    du -hs "${ORIG_DRIVE_MOUNTPATH}"
    df -h "${ORIG_DRIVE_MOUNTPATH}"
    sudo parted ${DRIVE_DEV} --script -- print
    # note following fails without specified ${DRIVE_DEV} ?!?
    sudo parted ${DRIVE_DEV} --script -- print devices

However I am unable to avoid--or, better yet, to script so as to 
satisfy--prompts from 

$ sudo parted ${DRIVE_DEV} --script -- rm 1
> Warning: Partition /dev/sdb1 is being used. Are you sure you want to continue?

This seems wrong to me, in 2 ways:

1. The manual[2] says quite clearly
> ‘-s’
> ‘--script’
> never prompt the user

So ISTM[3] either something is wrong with the code or with the manual. Am I 
missing something? 

2. I can't find a way to script a response to the prompt. I have tried various 
permutations of

    echo 'yes' | sudo parted ${DRIVE_DEV} --script -- rm 1
    yes | sudo parted ${DRIVE_DEV} --script -- rm 1
    yes Y | sudo parted ${DRIVE_DEV} --script -- rm 1
    sudo sh -c "yes yes | sudo parted ${DRIVE_DEV} --script -- rm 1"

So ISTM one of 2 cases applies here:

1. `rm` is (deliberately) unscriptable. If so, ISTM this should be duly noted 
in the manual, e.g. here[4]

2. `rm` is scriptable, or the user needs to make some configuration change if 
s/he wants to script `rm`. If so, how? and again, the necessary instructions 
should also be provided in the manual (same place[4]), since it's obviously 
non-trivial.

In case it matters, I'm running Debian 8 with up-to-date (for that distro) 
`bash` and `parted`, particularly

$ date; sudo parted --version | head -1
> Fri Aug 12 15:42:45 MST 2016
> parted (GNU parted) 3.2

TIA, Tom Roche <address@hidden>

[1]: https://en.wiktionary.org/wiki/WFM
[2]: https://www.gnu.org/software/parted/manual/parted.html#Invoking-Parted
[3]: https://en.wiktionary.org/wiki/ISTM
[4]: https://www.gnu.org/software/parted/manual/parted.html#rm





reply via email to

[Prev in Thread] Current Thread [Next in Thread]