Here is current process:
From Windows NT command line, navigate to directory that has the
target files
ftp 10.1.7.9 (unix address)
Enter in username
Enter in password
cd /long/drawed/out/directory/wish/it/was/shorter
mput *.ssc
Is there a way to automate this? I'm a novice.
Also, the next question was similar. I want to automate process of
telnet to a site that does the following
telnet 10.1.7.9 (unix address)
username
password
cd \directory\located\here
ascii
hash
prompt
rm filename
y
nohup file &
TIA
ziggs wrote:
>
> From a Windows NT screen, I was trying to find a way to automate a
> particular process that copies a few files from Windows NT to UNIX
> through FTP.
You're asking how to do it on windows right? This is comp.unix.questions. You
need to ask some windows folks.
You could install one of the UNIX-like environments that run on Windows and use
them... cygwin from redhat, uwin from
http://www.research.att.com/sw/tools/uwin/
for example.
-- ced
>
> Here is current process:
>
> From Windows NT command line, navigate to directory that has the
> target files
> ftp 10.1.7.9 (unix address)
> Enter in username
> Enter in password
> cd /long/drawed/out/directory/wish/it/was/shorter
> mput *.ssc
>
> Is there a way to automate this? I'm a novice.
>
> Also, the next question was similar. I want to automate process of
> telnet to a site that does the following
>
> telnet 10.1.7.9 (unix address)
> username
> password
> cd \directory\located\here
> ascii
> hash
> prompt
> rm filename
> y
> nohup file &
>
> TIA
--
Chuck Dillon
Senior Software Engineer
Accelrys Inc., a subsidiary of Pharmacopeia, Inc.
> From a Windows NT screen, I was trying to find a way to automate a
> particular process that copies a few files from Windows NT to UNIX
> through FTP.
>
Your question deals with programming the CMD shell in WNT.
Not many here will happily attempt that.
Possibilities:
$$$
Buy Visual Studio
Buy some ActiveX wrappers for common TCP/IP functions (telnet, ftp,
sendmail, etc.)
Write a bunch of code (and get a sore "mouse elbow" by pointing,
highlighting, selecting, clicking, dragging, etc. etc.) to automate
the whole schmeer.
OR
FREE
get a free bash shell for Windows NT
Search groups.google.com for information on automating ftp, telnet
sessions.
write a script (or two) of less than 20 lines to automate the whole
schmeer.
Ah, yes. The future is absolutely pregnant with possibility.
:-)
Cheers
Dave
+-----------------------+-----------------+-----------+
| nojun...@nospam.com | southbell net | swap bell |
| nos...@nojunkmail.com | davegrantier at | and south |
+-----------------------+-----------------+-----------+
You'll have to learn some of the Perl language, but I've posted a chunk
of code that I wrote that does an automated ftp. This is a code fragment
and you'll have to write a code around it that customizes it for your
environment. I've changed several variable to hide the name of the
company that I wrote it for. I basically logs in to $ftp_server using
$ftp_user and $ftp_password, changes to "my_directory" and gets a few
files. Just replace the $ftp->get with $ftp->put to upload files to
$ftp_server. Though you'll have to learn some Perl, this is by far the
easiest way to automate and reuse an ftp process. If you want to learn
some Perl, try starting out at http://www.perl.com. Good luck.
require Net::FTP;
print "$sourcedir not found. Attempting to install via ftp from
$ftp_server...\n";
my $ftp = Net::FTP->new( $ftp_server ) || die "Could not create TFP
object: $!";
$ftp->login( $ftp_user, $ftp_password ) || die "Could not login to
$ftp_server: $!\n";
$ftp->cwd("my_directory");
$ftp->get("some_file_name", $some_local_folder) || die "Could not
get $some_file_name: $!\n";
$ftp->cwd($another_directory) || die "Could not cd to
$another_directory: $!\n";;
print "Changed directory to $another_directory...\n";
my @files = $ftp->ls();
##$ftp->type("binary");
##print join( "\t", @files ), "\n";
foreach my $bin ( grep /^Some_pattern/i, @files ) {
$ftp->binary();
$ftp->get("$bin", "$installdir/bin/$bin" ) ||
die "Could not copy $bin to $installdir/bin...\n";
print "Got $bin. Proceeding...\n";
}
foreach my $lib ( grep /^lib/, ( $ftp->ls() ) ) {
$ftp->binary();
$ftp->get("$lib", "$installdir/shlib/$lib" ) ||
die "Could not put $lib in $installdir/shlib...$!\n";
print "Got $lib. Proceeding...\n";
system("cp", "$installdir/shlib/$lib", "$locallib") &&
die "Could not copy $lib to $locallib...$!\n";
print "Copied $lib to $locallib. Proceeding...\n";
}
$ftp->quit;
another option here would be to set up an ftp server on the nt box and write
a script (perl, or expect) on the UNIX server to _get_ the files - don't
have to install perl on hte nt box that way, and ftp server is natively part
of nt (server at least by default). If you want more security or otherwise
don't want to run nt's ftp server (IIS), install GuildFTP, available at
http://www.nitrolic.com.
> > Also, the next question was similar. I want to automate process of
> > telnet to a site that does the following
> >
> > telnet 10.1.7.9 (unix address)
> > username
> > password
> > cd \directory\located\here
> > ascii
> > hash
> > prompt
> > rm filename
> > y
> > nohup file &
is there a particular reason that you want to control this process from the
NT machine? You could just as easily schedule a script to run on the UNIX
server and it would take care of all of this more reliably and without
depending on the network.
script sample:
--beginning of script--
#!/bin/sh
/usr/bin/rm -f /directory/located/here/filename
nohup /full/path/to/file &
--end of script--
rm -f will avoid the confirmation which you are having to answer in your
current process.
run the script from cron (see man cron) whenever you like - if the network
link from the nt box to the unix goes dead, the file(s) will still be
removed and the process will still be started. put the script in whichever
user's crontab that was logging in via a telnet session (as you described
above)...
nc
If you can arrange it so that the UNIX ftp "puts" to the NT instead,
then the UNIX script looks like this:
ftp -n NTmachineIP <<%%
user anonymous j...@no.com
cd pub/incoming
binary
put file
quit
%%
have a cron launch this job and then the UNIX will push the file to NT.
Joe H.