hakermania
February 21st, 2010, 03:22 PM
Hi, I made this script which works perfectly:
clear
echo " 1 = Login
2 = Change the Login Password
3 = Forgot your password?
4 = Set the recall answer to question
"
read number
case $number in
1)
if [ -s /home/alex/Documents/PASS/password_PASS ]; then
existpass=`cat /home/alex/Documents/PASS/password_PASS`
echo "Type the existing pass:"
read givenpassasexisted
if [ "$existpass" == "$givenpassasexisted" ]; then
clear; echo "Success!"
else echo "Bad"
exit
fi
else echo "There is no password."
fi;;
2)
if [ -s /home/alex/Documents/PASS/password_PASS ]; then
existpass=`cat /home/alex/Documents/PASS/password_PASS`
echo "Type the existing pass:"
read givenpassasexisted
if [ "$existpass" == "$givenpassasexisted" ]; then
echo "Type new password:"
read newpass
cd /home/alex/Documents/PASS/
rm password_PASS
echo $newpass > /home/alex/Documents/PASS/password_PASS
echo $newpass > /home/alex/Documents/PASS/bringagain_PASS
else
echo "Wrong password.Plz retry"
fi
else echo "there is no password file.Create one plz."
fi;;
3)
echo "Which is your best friend?"
read maybebestfriend
realbestfriend=`cat /home/alex/Documents/PASS/recallquestion_PASS`
if [ "$maybebestfriend" == "$realbestfriend" ]; then
recall=`cat /home/alex/Documents/PASS/bringagain_PASS`
echo "The password which you forgot is $recall"
else
echo "Wrong answer to the question which is your best friend.Try again."
fi;;
4)
echo "Which is the current password?"
read givenpassasexisted
existpass=`cat /home/alex/Documents/PASS/password_PASS`
if [ "$existpass" == "$givenpassasexisted" ]; then
echo "Which is your best friend?"
read bestfriend
echo $bestfriend > /home/alex/Documents/PASS/recallquestion_PASS
else
echo "Wrong password.Try again!"
fi
esac
I also made a C program like this:
#include <stdlib.h>
int main()
{
system("/home/alex/Documents/PASS/hi");
return 0;
}
The problem is that when I type the script in console (./scriptname)
It works fine.When I call it via the C then it says
[: 67: popopo: unexpected operator
WHY?
clear
echo " 1 = Login
2 = Change the Login Password
3 = Forgot your password?
4 = Set the recall answer to question
"
read number
case $number in
1)
if [ -s /home/alex/Documents/PASS/password_PASS ]; then
existpass=`cat /home/alex/Documents/PASS/password_PASS`
echo "Type the existing pass:"
read givenpassasexisted
if [ "$existpass" == "$givenpassasexisted" ]; then
clear; echo "Success!"
else echo "Bad"
exit
fi
else echo "There is no password."
fi;;
2)
if [ -s /home/alex/Documents/PASS/password_PASS ]; then
existpass=`cat /home/alex/Documents/PASS/password_PASS`
echo "Type the existing pass:"
read givenpassasexisted
if [ "$existpass" == "$givenpassasexisted" ]; then
echo "Type new password:"
read newpass
cd /home/alex/Documents/PASS/
rm password_PASS
echo $newpass > /home/alex/Documents/PASS/password_PASS
echo $newpass > /home/alex/Documents/PASS/bringagain_PASS
else
echo "Wrong password.Plz retry"
fi
else echo "there is no password file.Create one plz."
fi;;
3)
echo "Which is your best friend?"
read maybebestfriend
realbestfriend=`cat /home/alex/Documents/PASS/recallquestion_PASS`
if [ "$maybebestfriend" == "$realbestfriend" ]; then
recall=`cat /home/alex/Documents/PASS/bringagain_PASS`
echo "The password which you forgot is $recall"
else
echo "Wrong answer to the question which is your best friend.Try again."
fi;;
4)
echo "Which is the current password?"
read givenpassasexisted
existpass=`cat /home/alex/Documents/PASS/password_PASS`
if [ "$existpass" == "$givenpassasexisted" ]; then
echo "Which is your best friend?"
read bestfriend
echo $bestfriend > /home/alex/Documents/PASS/recallquestion_PASS
else
echo "Wrong password.Try again!"
fi
esac
I also made a C program like this:
#include <stdlib.h>
int main()
{
system("/home/alex/Documents/PASS/hi");
return 0;
}
The problem is that when I type the script in console (./scriptname)
It works fine.When I call it via the C then it says
[: 67: popopo: unexpected operator
WHY?