Telnet Script

Hi,
I have the following code ...

(sleep 1; echo $USERID ; sleep 1; echo $PASSWD ; sleep 1 ; echo y ; sleep 1 ; echo "\r" ; sleep 1 ; echo "cd $FILEPATH" ; sleep 1 ; echo "pwd"; sleep 1 ; echo df -k .| tail -1| cut -d ' ' -f8 > aop.txt ; echo "pwd" ; cat aop.txt; sleep 3)| telnet $SERVER

the problem is that if i want to get the value returned by df -k . command i am not able to store that value in a variable. If i redirect the output to a file and cat it then it's working fine but when i am opening that file manually it is displaying me the command that i have typed in. Extremely confused.
Thanks :slight_smile:

please split your long lines!

your problem is that you are sending the text "df -k ." into the tail |cut pipeline, and the return from that is an empty string. If you wanted to assign the output to a variable just do:

VAR=$(df -k .|tail -1|cut -d " " -f8)

or replace the $() with backticks