Thanks
Roh
EggHeadCafe - Software Developer Portal of Choice
Professional ASP.NET Web Services [Wrox]
http://www.eggheadcafe.com/tutorials/aspnet/3ef0c5cd-a221-4376-a2a0-dfe7948c05a1/professional-aspnet-web.aspx
If you are looking for an executable under a Unix/Posix-like system shell
which filename
or
whence filename
may work for you, if it is in your search path.
If it is just a random file
find / -name "filename"
will search the entire directory tree for the file.
import sys
import telnetlib
# make the connection, with possible timeout
try:
tn = telnetlib.Telnet()
tn.open("10.4.1.54", 23)
except:
print "telnetlib.Telnet error:", sys.exc_info()[0], sys.exc_info()[1]
sys.exit(1)
# enter username and password at prompts
tn.read_until("login: ")
tn.write("al\n")
tn.read_until("Password:")
tn.write("fansome\n")
# send the command file to the session
tn.write("which time\n")
# end the session by exiting the shell
tn.write("exit\n")
# read back the output from the session
try:
output = tn.read_all()
except:
print "tn.read_all error:", sys.exc_info()[0], sys.exc_info()[1]
tn.close()
sys.exit(0)
print output
> I need to write a script which can run on windows (hence considering
> Powershell) which can log into a remote unix server and retrieve full path
> of file given the filename. Can this be done using Powershell? If not can
> i do this using any other tools on windows? I am considering using plink
> w/ powershell but cant find enough examples? If possible please provide
> with ps plink command statement.
I won't try to answer your question since I'm not that experienced with PS
and there are others here who are far more qualified to answer it than I am.
However, I do have one comment to make that's not related only to
Powershell: assuming that you're doing this for your employer and not as a
personal toy, what plans do you have for security? You need to consider not
only the obvious one of having to somehow secure the script if it contains a
hardcoded userid and password, but also the process for periodic changes to
the password (and coordinating the changes on the remote host with changes
to the script). You also should consider using something more secure that
plain-vanilla telnet, which sends everything (including the login userid and
password) across the network in cleartext.
Joe Morris
Al Fansome wrote:
Python will do this, using the standard Python telnetlib.
07-Nov-09
Python will do this, using the standard Python telnetlib. It lets you
telnet into a system, such as UNIX, and feed the shell there command
lines. I have been using Python 2.6.2 under Windows XP and PowerShell 1
& 2 for some time now to remotely access a large number of remote POSIX
(QNX) systems, and they complement each other nicely.
If you are looking for an executable under a Unix/Posix-like system shell
which filename
or
whence filename
may work for you, if it is in your search path.
If it is just a random file
find / -name "filename"
will search the entire directory tree for the file.
roh wrote:
Previous Posts In This Thread:
EggHeadCafe - Software Developer Portal of Choice
Confirm Message Box before Deleting
http://www.eggheadcafe.com/tutorials/aspnet/4f445b0a-bb25-4030-8f9b-0ff1ac5655d4/confirm-message-box-befor.aspx
"roh" wrote in message news:200911813473...@gmail.com...
I've used this before, and it works: http://huddledmasses.org/scriptable-ssh-from-powershell/
Log into how? Telnet, FTP...something else?
Likely you can do this with Powershell but you are going
to need the specific service/server to emulate such a client
in Powershell, or run some external program that does this
like nc.exe (available on the Internet) to actually converse
with the service on Unix, do the directory listing (or whatever)
and return the answers to Powershell for parsing or
processing.