Last active
November 13, 2015 00:24
-
-
Save dukwon/ee08c1a0df93f9ec5403 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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