Quantcast
Channel: linuxadmin: Expanding Linux SysAdmin knowledge
Viewing all articles
Browse latest Browse all 17793

Script runs commands in reverse?

$
0
0

Hey guys, I'm working on a small script on Ubuntu but for some reason it is running some commands backwards which I think may be screwing some stuff up.

Here is a snippet:

 TMPDIR="`mktemp -d --tmpdir=/tmp wipe.XXXXX`" TMPDISK="`mktemp --tmpdir=${TMPDIR} wipe.XXXXX`" fdisk -l | grep "Disk /dev/sd" | grep "bytes" | grep -v "/dev/sd[abcd]\|/dev/md0" > ${TMPDISK} #clear cat ${TMPDISK} printf "Enter drive to be wiped (/dev/sdX): " read drive 

When I run it on my work station, I get the following (with set -x)

+ TMPDISK=/tmp/wipe.lD0UA/wipe.FIqnH + grep 'Disk /dev/sd' + fdisk -l + grep bytes + grep -v '/dev/sd[abcd]\|/dev/md0' + cat /tmp/wipe.lD0UA/wipe.FIqnH Disk /dev/sde: 3221 MB, 3221225472 bytes + printf 'Enter drive to be wiped (/dev/sdX): ' Enter drive to be wiped (/dev/sdX): + read drive 

When I run it on a stock install, I get the following when using set -x:

+ TMPDISK=/tmp/wipe.K0XYI/wipe.mwfFR + grep -v '/dev/sd[abcd]\|/dev/md0' + grep bytes + grep 'Disk /dev/sd' + fdisk -l 

It seems to go through the functions ok but it never gets to the prompt and just closes without any output.

From the looks of it, it starts to run the fdisk -l and then starts grepping backwards. Anyone seen this behavior before? I searched around online but all I can find is tutorials on creating a script to reverse the entirety of a book and not something that would cause this.

submitted by amperages
[link][1 comment]

Viewing all articles
Browse latest Browse all 17793

Trending Articles