Skip to content

Instantly share code, notes, and snippets.

@dukwon
Last active November 13, 2015 00:24
Show Gist options
  • Save dukwon/ee08c1a0df93f9ec5403 to your computer and use it in GitHub Desktop.
Save dukwon/ee08c1a0df93f9ec5403 to your computer and use it in GitHub Desktop.
#!/bin/bash
vps='188.166.55.237'
fmt='mp3'
codec='libmp3lame'
ffmpeg -f alsa -i pulse -acodec $codec -ab 96k -y "output.$fmt"
name=$(cat /dev/urandom | tr -dc "a-zA-Z0-9" | fold -w 6 | head -n 1)
existing=($(ssh $vps ls /var/www/html/*.$fmt | sed -r "s/\/var\/www\/html\/(\w*)\.$fmt/\1/"))
while [[ " ${existing[@]} " =~ " ${name} " ]]
do
echo "A file named $name.$fmt already exists on server."
name=$(cat /dev/urandom | tr -dc "a-zA-Z0-9" | fold -w 6 | head -n 1)
echo "Trying $name.$fmt"
done
scp output.$fmt ${vps}:/var/www/html/$name.$fmt
echo "http://${vps}/$name.$fmt"
rm output.$fmt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment