Code:
function forcd
{
len=`wc -c ~/Pictures/file2 | cut -c1-2`
echo $len
cutcmd=`cut -c4-$len ~/Pictures/file2`
echo $cutcmd
cd $cutcmd
}
newvar=`pwd`
clear
echo "root"$newvar">"
read cmd
until [ "$cmd" == "exit" ];
do
echo $cmd > ~/Pictures/file1
cutcmd2=`cut -c1-2 ~/Pictures/file1`
echo $cutcmd2
if [ "$cmd" == "dir" ]; then
ls -l
elif [ "$cmd" == "dir /p" ]; then
ls -l | more
elif [ "$cmd" == "cd .." ]; then
cd ../
elif [ "$cutcmd2" == "cd" ]; then
echo $?
echo $cmd > ~/Pictures/file2
forcd
elif [ "$cmd" == "cls" ]; then
clear
else echo "ERROR-----> Invalid filename or command......!!!!!!"
fi
newvar=`pwd`
echo "root"$newvar">"
read cmd
done
I tried to make a DOS emulator.
I am having problem in executing the 'cd <directory_name>' command.
There is some problem in 'cutcmd2'. It is supposed to be 'cd' but it always empty.
I made two files in ~/Documents ---> file1, file2.
But when I execute this script...another file with the name 'file1?' is created which I guess is the problem...!!!
Please help...!!!!!ASAP