Results 1 to 4 of 4

Thread: sgdisk behaviour

  1. #1
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,015

    Default sgdisk behaviour

    Hello.

    1°) When I run this piece of code :
    Code:
    ...
        echo "sgdisk -d $DEVICE_PARTNUMBER  $DISK_DEVICE"
        echo " "
        sgdisk -d "$DEVICE_PARTNUMBER  $DISK_DEVICE"
        RET_CODE=$?
        echo "\$?   : $RET_CODE"
    
    ....
    I got this error :
    Code:
    sgdisk -d 1  /dev/sdd
     
    Problem opening   /dev/sdd for reading! Error is 2.
    The specified file does not exist!
    $?   : 2
    2°) When I use bash "eval" command
    Code:
    .....
         CMD="sgdisk -d $DEVICE_PARTNUMBER  $DISK_DEVICE"
        echo "CMD : $CMD"
        eval "$CMD"
        RET_CODE1=${PIPESTATUS[@]}
        RET_CODE2=$?
        echo "PIPE STATUS : $RET_CODE1"
        echo "\$?          : $RET_CODE2"
    ....
    I got no error :
    Code:
    CMD : sgdisk -d 1  /dev/sdd
    Warning: The kernel is still using the old partition table.
    The new table will be used at the next reboot.
    The operation has completed successfully.
    PIPE STATUS : 0
    $?                : 0
    3°) When I run this command from a kde console I got no error :
    Code:
    sgdisk -d 1  /dev/sdd
    Warning: The kernel is still using the old partition table.
    The new table will be used at the next reboot.
    The operation has completed successfully.
    Any help is welcome.
    Thanks for helping. JCD
    __________

    server leap 15-- ASUS g75vw KDE leap 42.3 -- ASUS g750JZ KDE leap 42.3 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

  2. #2
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,175
    Blog Entries
    3

    Default Re: sgdisk behaviour

    Quote Originally Posted by jcdole View Post
    Hello.

    1°) When I run this piece of code :
    Code:
    ...
        echo "sgdisk -d $DEVICE_PARTNUMBER  $DISK_DEVICE"
        echo " "
        sgdisk -d "$DEVICE_PARTNUMBER  $DISK_DEVICE"
        RET_CODE=$?
        echo "\$?   : $RET_CODE"
    
    ....
    I'm not sure what you are trying to do there.

    When you use:
    Code:
    sgdisk -d "$DEVICE_PARTNUMBER  $DISK_DEVICE"
    you are doing something like:
    Code:
    sgdisk -d weird-device-name-that-contains-spaces
    That's because of your quoting.

    You presumably needed either:
    Code:
    sgdisk -d $DEVICE_PARTNUMBER  $DISK_DEVICE
    or
    Code:
    sgdisk -d "$DEVICE_PARTNUMBER"  "$DISK_DEVICE"
    so that there are two arguments following the "-d".

    When you use "eval", the "eval" removes the quotes and parses the string before running the command. So the problem with quotes is no longer there.

    I'm not sure what you thought you were asking about. I'm taking your post as a question about shell quoting.
    openSUSE Leap 15.1; KDE Plasma 5;

  3. #3
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,015

    Default Re: sgdisk behaviour

    Quote Originally Posted by nrickert View Post
    I'm not sure what you are trying to do there.

    When you use:
    Code:
    sgdisk -d "$DEVICE_PARTNUMBER  $DISK_DEVICE"
    you are doing something like:
    Code:
    sgdisk -d weird-device-name-that-contains-spaces
    That's because of your quoting.

    You presumably needed either:
    Code:
    sgdisk -d $DEVICE_PARTNUMBER  $DISK_DEVICE
    or
    Code:
    sgdisk -d "$DEVICE_PARTNUMBER"  "$DISK_DEVICE"
    so that there are two arguments following the "-d".

    When you use "eval", the "eval" removes the quotes and parses the string before running the command. So the problem with quotes is no longer there.

    I'm not sure what you thought you were asking about. I'm taking your post as a question about shell quoting.
    Because I had not seen that I have misquoted the statement (surely tired) I was wondering why it was behaving differently.
    Of course the correct syntax is
    Code:
    sgdisk -d "$DEVICE_PARTNUMBER"  "$DISK_DEVICE"
    Thank you to see it.
    Thanks for helping. JCD
    __________

    server leap 15-- ASUS g75vw KDE leap 42.3 -- ASUS g750JZ KDE leap 42.3 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

  4. #4
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,015

    Default Re: sgdisk behaviour

    Quote Originally Posted by nrickert View Post
    ...

    And happy new year !
    Thanks for helping. JCD
    __________

    server leap 15-- ASUS g75vw KDE leap 42.3 -- ASUS g750JZ KDE leap 42.3 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •