Hey there, I don't think you can just run that `if(-d $filesystem)...` bit once you've telnet'd into the server, you're going to have to send the command through the telnet object.
Let's say you want to see if /mnt/blah exists, you can run something like this: