Hej, du har kommit hit för att leta efter betydelsen av ordet
Utilizator:Flubot/rename.sh. I DICTIOUS hittar du inte bara alla ordboksbetydelser av ordet
Utilizator:Flubot/rename.sh, utan du får också veta mer om dess etymologi, dess egenskaper och hur man säger
Utilizator:Flubot/rename.sh i singular och plural. Allt du behöver veta om ordet
Utilizator:Flubot/rename.sh finns här. Definitionen av ordet
Utilizator:Flubot/rename.sh hjälper dig att vara mer exakt och korrekt när du talar eller skriver dina texter. Genom att känna till definitionen av
Utilizator:Flubot/rename.sh och andra ord berikar du ditt ordförråd och får tillgång till fler och bättre språkliga resurser.
#!/bin/bash
cookiesfile="rowikt-login-cookies.txt"
wiki="ro.wiktionary.org"
#username, password
lgname="Flubot"
lgpassword="XXXXXXXXXXXXX"
reason1=""
curlargs="-s -S --retry 10 -H 'Expect:' -c $cookiesfile -b $cookiesfile -f"
curlurl="http://$wiki/w/api.php?action="
if ; then
reason_arg="--data-urlencode reason=$reason1"
#summary_arg="--data-urlencode 'summary=$reason1'"
else
reason_arg=""
#summary_arg=""
fi
function getxmlitem()
{
xmlitemval=`echo $xmltext | tr '>' '\n' | grep ${tokenname}= | awk -F${tokenname}= '{ print $2 }' | awk -F'"' '{ print $2 }'`
}
function loginerrcheck() {
if ; then
echo "Login failed, maybe wrong password"
if ; then
rm -f $cookiesfile
fi
exit 1
fi
loginerr=`echo $login | grep Illegal`
if ; then
echo "Login failed, maybe wrong password"
echo " More information:"
echo " $loginerr" | sed -e "s/'/'/g;"
if ; then
rm -f $cookiesfile
fi
exit 1
fi
return
}
function login() {
if ; then
echo "Edit this file and change variables"
echo "lgname και lgpassword."
exit 1
fi
login=`curl -s -S --retry 10 -H 'Expect:' -c $cookiesfile -f --data-urlencode "lgname=$lgname" --data-urlencode "lgpassword=$lgpassword" --data-urlencode "format=xml" "${curlurl}login"`
loginresult=$?
loginerrcheck
loginneedtoken=`echo $login | grep NeedToken`
if ; then
tokenname=token
xmltext="$login"
getxmlitem
lgtoken="$xmlitemval"
login=`curl -s -S --retry 10 -H 'Expect:' -c $cookiesfile -b $cookiesfile -f --data-urlencode "lgname=$lgname" --data-urlencode "lgpassword=$lgpassword" --data-urlencode "lgtoken=$lgtoken" --data-urlencode "format=xml" "${curlurl}login"`
loginresult=$?
loginerrcheck
loginneedtoken=`echo $login | grep NeedToken`
if ; then
echo "Login failed (NeedToken after second attempt)"
if ; then
rm -f $cookiesfile
fi
exit 1
fi
fi
echo "You are logged in as $lgname"
}
function movepagefromtitle() {
xmltext=`curl $curlargs -d "prop=info" -d "format=xml" --data-urlencode "titles=$title" "${curlurl}query"`
redir=`echo $xmltext | grep 'redirect' -c`
if ; then
xmltext=`curl $curlargs --data-urlencode "prop=info" --data-urlencode "intoken=move" --data-urlencode "format=xml" --data-urlencode "titles=$title" "${curlurl}query"`
tokenname=movetoken
getxmlitem
movtoken="$xmlitemval"
if ; then
echo "Apply for movtoken failed, you may have not rights"
echo " More information:"
echo " $xmltext" | sed -e "s/'/'/g;"
return 1
fi
title1=`echo $title | sed -e 's/ţ/ț/g'`
title2=`echo $title1 | sed -e 's/ş/ș/g'`
echo "$title2"
result=`curl $curlargs --data-urlencode "format=xml" --data-urlencode "token=$movtoken" --data-urlencode "from=$title" --data-urlencode "to=$title2" $reason_arg "${curlurl}move" `
if ; then
echo "Moving failed"
return 1
fi
err=`echo $result | grep -i error`
if ; then
echo "$title" "Moving failed... or made by someone else"
echo " More information:"
echo "$err" | sed -e "s/'/'/g;" | awk -F 'error' '{ print $2 }' | awk -F '/>' '{ print $1 }'
fi
else
echo "$title" " : it is a redirect, not moved"
return 1
fi
}
function checkusage() {
if ; then
echo "Χρήση: $0 1η-λέξη 2η-λέξη 3η..."
echo "Your account must have moving rights."
echo "Attention: Every headword including spaces must be written between quotes"
echo "For example:"
echo "$0 'mean vandal' 'super mean vandal' 'boring editwar type'"
echo "Alternatively, you can call this script with"
echo "cat file-with-words | $0 -"
echo "and it will read the headwords' list from stdin."
exit 1
fi
}
## MAIN
##
checkusage $#
if ; then
login
fi
if ; then
while read title; do
movepagefromtitle
done
else
for title in "$@"; do
movepagefromtitle
done
fi