1. Post #1
    Facepunch iSeries!
    rieda1589's Avatar
    November 2007
    4,098 Posts
    Basically, I'm making a screenshot script, it'll let me drag a rectangle, upload the image and put the URL in my clipboard.

    Everything is fine, except I can't get the name randomized.

    I've tried a shit load of stuff... including

    Code:
    cat /dev/urandom | tr -cd 'a-zA-Z0-9-_' | head -c 3
    But I just get

    ben@ben-ubuntu:~/.imageup$ ./window.sh
    ./window.sh: line 6: /dev/urandom: Permission denied
    Any help?

    Here's my script

    Code:
    #!/bin/bash -e
    
    IMGDIR=~/.imageup
    cd $IMGDIR
    
    #IMG=cat /dev/urandom | tr -cd 'a-zA-Z0-9-_' | head -c 3
    IMG=$(date +%Y%m%d%H%M%S)
    EXT=.png
    ICON="/home/ben/.icons/elementary/places/128/network.svg"
    
    scrot -d 0 -b -s -q 1 $IMG$EXT
    notify-send -i $ICON $IMG$EXT "Captured"
    
    HOST="somewhere"
    USER="somebody"
    PASSWD="something"
    
    ftp -n $HOST <<EOF
    quote USER $USER
    quote PASS $PASSWD
    cd /home/ben/benbrooks.co.uk/img/
    put $IMG$EXT
    EOF
    
    echo "http://bbrks.me/i/$IMG$EXT" | xclip -selection clipboard
    notify-send -i $ICON $IMG$EXT "Uploaded!"
    #rm $IMG
    I need the $IMG randomized, lowercase, uppercase, numbers and - _ (as seen in the /dev/urandom snippet)

  2. Post #2
    Gold Member
    butre's Avatar
    July 2008
    19,896 Posts
    try using cut?

  3. Post #3

    July 2009
    55 Posts
    Is this what you are trying to do?
    Code:
    IMG=</dev/urandom tr -cd 'a-zA-Z0-9-_' | head -c 3
    echo $IMG
    Edit: Check my post below for the correct code.

  4. Post #4
    Facepunch iSeries!
    rieda1589's Avatar
    November 2007
    4,098 Posts
    Is this what you are trying to do?
    Code:
    IMG=</dev/urandom tr -cd 'a-zA-Z0-9-_' | head -c 3
    echo $IMG
    Not quite.

    Code:
    IMG=</dev/urandom tr -cd 'a-zA-Z0-9-_' | head -c 3
    Having IMG as that basically does this:

    ben@ben-ubuntu:~$ sh ~/.imageup/window.sh
    CpZ
    And then $IMG doesn't seem to be anything, so the URL that gets put in my clipboard is just "http://bbrks.me/i/".

  5. Post #5

    July 2009
    55 Posts
    I think I fixed it.
    Code:
    IMG=`cat /dev/urandom | tr -cd 'a-zA-Z0-9-_' | head -c 3`
    echo "http://bbrks.me/i/$IMG"
    Reply With Quote Edit / Delete Reply United States Show Events Friendly Friendly x 1 (list)

  6. Post #6
    Facepunch iSeries!
    rieda1589's Avatar
    November 2007
    4,098 Posts
    I think I fixed it.
    Code:
    IMG=`cat /dev/urandom | tr -cd 'a-zA-Z0-9-_' | head -c 3`
    echo "http://bbrks.me/i/$IMG"
    It worked!!



    Thanks :)

  7. Post #7
    Facepunch iSeries!
    rieda1589's Avatar
    November 2007
    4,098 Posts
    By the way, Just in case anybody is using the window script and it won't work via a hotkey.

    You'll need to add a sleep 0.25; just before the scrot command, else it won't work properly.


  8. Post #8
    Gold Member
    Lego399's Avatar
    January 2007
    1,681 Posts
    By the way, Just in case anybody is using the window script and it won't work via a hotkey.

    You'll need to add a sleep 0.25; just before the scrot command, else it won't work properly.

    My AnyHub script is working fine without it

  9. Post #9
    Facepunch iSeries!
    rieda1589's Avatar
    November 2007
    4,098 Posts
    My AnyHub script is working fine without it
    Weird... It just captures an empty image if I don't add that sleep.

  10. Post #10

    November 2009
    2,435 Posts
    Code:
    touch <smash keyboard>
    Reply With Quote Edit / Delete Reply United States Show Events Bad Reading Bad Reading x 1Useful Useful x 1 (list)

  11. Post #11
    Gold Member
    turb_'s Avatar
    February 2010
    2,182 Posts
    The proper way would be mktemp