Run and show Batch file commands on telnet - windows

Not only for the host running. Bat, but to run and display the output text to the client (Telnet)
This is possible?
I have tried and tested everything and could not.
If it is not really possible, which file should I edit to edit the text output from telnet and what language is it?

from what little I understood, you just want to send the output of a file to another computer using telnet. if so try file | telnet. or... cough ...
you could use netcat, if it was one time and you were carful it shouldn't pose a huge threat.
nc -lp12123 on the server, and connect with nc server 12123 -efile.bat on the client.
if neither of these suit then please post more info.

Related

AS400 FTP to windows server

I want to write a CLLE Program to transfer Files from the IFS to a Webserver.
The Webserver is registered in the Hosttable from the Iseries.
(commandline: CFGTCP -> Option 10 -> Scroll to the Webserver IP)
Current CLLE Program: (only the ftp-access)
PGM
OVRDBF FILE(INPUT) TOFILE(CMDDTAR7_2/US9FIP) OVRSCOPE(*JOB)
OVRDBF FILE(OUTPUT) TOFILE(CMDDTAR7_2/US9FOP) +
OVRSCOPE(*JOB)
FTP RMTSYS('10.1.2.99')
ENDPGM
After i call my Program i get some results in a PF-File.
The Results are in German but i translated shortly for you.
The Connection is unavalable to 10.1.2.99 on Port 21. Try it again later.
[...]
My Question at the end.
Do you have some solutions for me to transfer xml files to my Webserver from the iseries?
You're writing about a web server and you want to transfer files by ftp. Perhaps you're mixing up protocols here. I'll concentrate to resolve your apparent ftp connection problem.
Seems that the destination host 10.1.2.99 doesn't accept connections on Port 21.
Please make sure, there's no firewall or other stuff blocking your request to the destination host. Moreover, on the host 10.1.2.99 try telnet 10.1.2.99 ftp or ftp 10.1.2.99 in a command window, depending on OS and installed components.
Before automating, just test manually if you can successfully connect and log in via standard command line: ftp 10.1.2.99.
Transferring data by FTP is just fine in a local LAN. Beware that any data including username and password will be transferred in clear text and thus can be possibly read by others as the intended hosts.
Following up to your comment: Actually there are many possibilities to copy files. If you're running a recent version of IBM i, I'd opt for using scp. It's encrypted and thus safe for running outside of local LANs. Great to automate by utilizing Key-Authentication instead of passwords. And many web hosting companies offer scp/sftp access.

Netcat FTP active mode file transfer not working

Im trying to download a file from a FTP server using active mode.However,it looks like my connection just"expire" or something each time.First,I open a port on my computer using netcat,ex:
nc -vv -l -p 62077
this will listen on port 62077 on my computer.Then,I open another netcat windows,log in to the FTP link using port 21,and once im in the directory where the file I want is in,I do
PORT (my IP separated by , ),(242,125(wich equals to port 62077)\r\n
However,after I enter this command,nothing happen for about 10-15 seconds,and the netcat just quit without saying anything.Nothing happen either on the netcat window that is listening on port 62077.It does that everytime,I dont know what I am doing wrong.I did the same thing with Filezilla(in active mode) and examinated the commands with wireshark,I do the exact same command as Filezilla,however filezilla will be able to retrieve the file while netcat wont.I want to retrieve it with netcat and I dont know what im doing wrong.I am using Windows 10.
thank you!
After you have established your listening nc socket, and after you have sent the USER, PASS, and PORT commands, you then need to trigger the file transfer to that listening socket using e.g.:
RETR /path/to/file/to/download
on the control connection. (Unless you actually are already doing this, but didn't mention it in the post?)
Also, just to note: you mention using something like this:
PORT 1,2,3,4,(242,125)\r\n
Right? Those parentheses might also be an issue. Instead, you might try:
PORT 1,2,3,4,242,125\r\n
without any parentheses.
Now, depending on the IP address you sent (hopefully not a private network address), the data transfer may still not happen, due to firewalls/routers/NAT on the client side of things. Given that your Filezilla download of the same file works, I suspect that those firewall/router/NAT issues may not apply.
Hope this helps!

Transferring files using Telnet

Is it possible to transfer files between two machines using Telnet protocol. From wikipedia,I understand that FTP & Telnet are similar. But on logging in using Telnet its very similar to logging into guest machine.
Please advise.
You cannot transfer a raw binary file over telnet because there are some codes that are reserved and will be escaped before transmission. Your local telnet terminal would also interpret other codes as cursor control sequences and go wild.
So no cat stuff.zip and extracting it locally from the log file or screen cut/paste.
However, you could encode a file into something safe using uuencode or base64, capture that on the local side, and decode it using the appropriate tool to get the original binary back.
But in short, just use FTP in "binary" plus "passive" mode. That's safest and what it's designed for.
That said, you should be using SSH instead of Telnet and then you can use SCP to transfer files.

Run command when user connects?

Is it possible to listen on a port and run a command when a user attempts to connect to that port? Ideal application is for a server that should only be run when someone is actually using it. Windows or Linux solutions work.
linux/unix:
man nc
NAME
nc - TCP/IP swiss army knife
some options that you may be interested
-l listen mode, for inbound connects
-p port local port number (port numbers can be individual or ranges: lo-hi [inclusive])
-e prog specify program to exec after connect (use with caution)
i think nc is also available under windows platform.
One solution could be via inetd or xinetd, specify the port number and a program to run, for you probably a shell script.
I am note sure what is the exact scope of a question but if bound to the programming-level, you could write your server in a way that when nobody is using it, no resources apart from the listening part are allocated. I would call it lazy initialization. When someone connects simply initialize the whole logic of your program. When all connections are gone, deinitialize everything.

Uploading to mainframe using FTP

I just want to know how you upload datasets specifying its characeteristics?
E.G. using the command quote site lrecl=500 recfm=fb
Well, the command was accepted when I tried to use it, but the problem is that when I tried to upload the file using the command 'send' ftp hangs up, and definitley closes the session.
This is the sample:http://www.mvsforums.com/helpboards/recent.php?sid=dab6b1f3cda149c7d7db855d90acaab1
ftp> quote site lrecl=500 recfm=fb
200 SITE command was accepted
ftp> send C:\test\test.txt 'ADM.SAMPLE.TEST'
200 Port request OK.
425 Can't open data connection.
ftp>
Any help will be appreciated.
Thanks.
I sometimes get this error because of firewall problems when trying to ftp behind a router. You might try switching to active or passive mode (depending of what you are currently using) to see if this helps.
I have a couple of programs that do this, but without specifying record size. The blocking command should be okay. Are you sure you don't have a permissions issue? Does ADM.SAMPLE.TEST already exist, and is it 500 bytes at least? If not, have them create it for you and see if the ftp works then.
You should be able to specify the data set allocation parameters using the site command.
site u=SYSDA rec=VB lr=6144 blk=0 ucount=2 tr pri=3000 sec=200
That translates to:
unit=SYSDA
record format=variable block
logical record length=6144
block size=0
unit count=2
track (allocation units)
primary space=3000
secondary space=200

Resources