Notification Completed Script File Script

I use Ubuntu to copy files contained in more than one hundred CDs to one hard drive. When the contents of the CD have finished copying to the hard drive, I do not receive any indication of its implementation. I would like to create a shell script that does the following:

  • Tell me a name to specify a new folder
  • Create a folder on the target hard drive
  • Copy the contents of the CD that is currently on the CD to a new folder
  • Notify me when the copy operation is complete

I installed libnotify on my computer, but I'm open to using other notification tools.

+3
source share
2 answers
#!/bin/bash
while read -r -p "Enter a folder name: " name
do
    [[ -z $name ]] && break    # quit if user presses enter without input
    mkdir -p "$name"
    cp source "$name"          # use your current copy method

    # Notifications: choose one or all six or add your own
    notify-send "Copy complete" "Folder: $name"
    zenity  --title="Copy complete" --text="Copying to folder $name is complete" --info&
    dialog --title "Copy complete" --msgbox "\nCopying to folder\n$name\nis complete\n" 10 60
    for i in {1..4}
    do
        printf '\a'            # make some noise
        sleep 1
    done
    echo "Copying to folder: $name is complete" | mail -S "Copy completion notification" keyslinger@example.com
    printf 'Copy to folder %s is complete.\n' "$name"
done
+3

, , ! , :

#!/bin/bash
while read -r -p "Enter a folder name: " name
do
    [[ -z $name ]] && break # quit if user presses enter without input
    cd /media/Iomega_HDD
    mkdir -p "$name"
    cdname=`volname`
    cdname=${cdname%% *}    #trim white space from variable holding cd name
    cdname=${cdname#* }
    cp -r /media/"$cdname"/. "$name"

    # Notifications:
    notify-send "Copy complete" "Folder: $name"
    printf 'Copy to folder %s is complete.\n' "$name"
    eject
done
+1

Source: https://habr.com/ru/post/1788860/


All Articles