#!/bin/bash
ip=`zenity --entry --title="iPhone" --text="iPhone's IP:"`;
pass=`zenity --entry --title="Passwort" --hide-text --text="Root Passwort"`;
(
while [ $# -gt 0 ]; do
		echo "# Konvertiere";
		infile=$1
		echo "10";
		file=`echo "$infile" | sed 's/\.\w*$//'`;
		outfile="$file.m4r"
		echo "20";
		mplayer -ao pcm "$infile" -ao pcm:file="/tmp/tmp.wav";
		echo "30";
		faac /tmp/tmp.wav -o "$outfile" -w;
		echo "40";
		rm "/tmp/tmp.wav";
		echo "50";
		echo "# Sende";
		/usr/bin/expect - << EndMark
set timeout -1
spawn scp "$outfile" root@$ip:/Library/Ringtones/
expect {
-re ".*Are.*.*yes.*no.*" { 
send "yes\r" 
exp_continue 
}

"*?assword:*" { 
send -- "$pass\r" 
send -- "\r" 
}
}
expect eof
EndMark
		echo "60"
		rm "$outfile";
		shift
	done
		echo "80";
		echo "# Fertig";
	) | zenity --progress --percentage=0 --auto-close --auto-kill;
exit 0

