-
telnet
Im making a little app to use at work when i have multipile emails to delete. since the email server I log on to to delete the emails doesnt have a delete all command i have to do it manualy
dele 1
dele 2
...
this is painful when you have 2000 to delete. im gonna make a loop with the ++ increment thingy.
my problem stoping me from going forward is how to make it execute that in a 3rd party app like telnet. how to make it that it logs in telnet with a username and pass and then execute my loop in telenet is whats troubling me.
Any ideas?
-
try rsh or expect
I would recommend you to use rsh to do so. If you really want to use telnet, you may need expect to control the session.
-
well i know how to do it in bash. but the thing is if i would make such a script, only I would have access to it. I want to make it so that all my collegues can use it also.
-
g++ -o popdel popdel.cpp
/usr/include/netdb.h: In function `int main(int, char**)':
/usr/include/netdb.h:137: too few arguments to function `hostent* gethostbyaddr(const void*, unsigned int, int)'
popdel.cpp:20: at this point in file
popdel.cpp:65: invalid conversion from `const char*' to `unsigned int'
popdel.cpp:65: invalid conversion from `int' to `const char*'
hehe im haing fun trying to debug this hehehe.
-
nice. it compiled without error. only problem is it doesnt work. it connects then after a momments it says done. and exits
Problem is that mail server is quit gay. when u login it will say
+OK b1gprt49 is welcome here
thats after sending user and pass.
To see how many msg i must send the list command first
list
+OK 2 messages
1 1274
2 1271
.
Im sure if we can squeez list in there it will work like charm
-
sorry man my bad. well it seem to be deleting something in background. but I think i found out why it doesnt acctualy work.
the problem is how the program exits. it doesnt send the QUIT string to the daemon. causing it to rset. I told u this server was gay lol.
close( s );
puts( "Done." );
return 0;
How would i translate that to become quit
-
man this works perfectly. thanks man. I wouldnt have done it without you.
-
to make this a port for dos. do i do this
from:
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
to:
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/winsock.h
#include <netdb.h>
where would i shove WSAStartup cause i have no clue how to use sockets in win32
-
does this look right to you?
Code:
#include <stdio.h>
#include <string.h>
#include <winsock.h>
int main( int argc, char *argv[] )
{
char buf[128];
int i,
s;
struct sockaddr_in server;
WSADATA wsa;
if( WSAStartup( MAKEWORD( 1, 1 ), &wsa ) ) {
perror( "Startup" );
return 1;
}
struct hostent *h;
if( argc != 4 ) {
fprintf( stderr, "Usage: ./prog server user password\n" );
return 1;
......
-
why are you so good man? how long have you been at this hehe
-
oups
--------------------Configuration: popdel32 - Win32 Debug--------------------
Compiling...
popdel32.cpp
c:\cpp\popdel32.cpp(40) : error C2065: 'snprintf' : undeclared identifier
c:\cpp\popdel32.cpp(42) : error C2065: 'close' : undeclared identifier
Error executing cl.exe.
popdel32.exe - 2 error(s), 0 warning(s)
this is lines 40 to 44
snprintf( buf, 128, "USER %s\r\n", argv[2] );
if( send( s, buf, strlen( buf ), 0 ) == -1 ) {
perror( "send" ), close( s );
return 1;
}
Im using visual c++ 6.0 enterprise to compile it.
now im lost hehe
-
hehe i did change it. now im getting errors when linking.
here is my code at this state. the error msg of the compiler (visual c++ 6) is under the code
Code:
#include <stdio.h>
#include <string.h>
#include <winsock.h>
int main( int argc, char *argv[] )
{
char buf[128];
int i,
s;
struct sockaddr_in server;
WSADATA wsa;
if( WSAStartup( MAKEWORD( 1, 1 ), &wsa ) ) {
perror( "Startup" );
return 1;
}
struct hostent *h;
if( argc != 4 ) {
fprintf( stderr, "Usage: ./prog server user password\n" );
return 1;
}
if( ( h = gethostbyname( argv[1] ) ) == NULL ) {
perror( "gethostbyaddr" );
return 1;
}
server.sin_addr = *( struct in_addr* )h->h_addr_list[0];
server.sin_port = htons( 110 );
server.sin_family = AF_INET;
s = socket( AF_INET, SOCK_STREAM, 0 );
if( s < 0 ) {
perror( "socket" );
return 1;
}
if( connect( s, ( struct sockaddr* )&server, sizeof( struct sockaddr )
) < 0 ) {
perror( "connect" );
return 1;
}
sprintf( buf, "USER %s\r\n", argv[2] );
if( send( s, buf, strlen( buf ), 0 ) == -1 ) {
perror( "send" ), closesocket( s );
return 1;
}
if( ( i = recv( s, buf, 128, 0 ) ) == -1 ) {
perror( "recv" ), closesocket( s );
return 1;
}
if( strncmp( buf, "+OK", 3 ) != 0 ) {
buf[i] = 0;
fprintf( stderr, "``%s''\n", buf ), closesocket( s );
return 1; }
sprintf( buf, "PASS %s\r\n", argv[3] );
if( send( s, buf, strlen( buf ), 0 ) == -1 ) {
perror( "send" ), closesocket( s );
return 1;
}
if( ( i = recv( s, buf, 128, 0 ) ) == -1 ) {
perror( "recv" );
return 1;
}
if( strncmp( buf, "+OK", 3 ) != 0 ) {
buf[i] = 0;
fprintf( stderr, "``%s''\n", buf );
}
for( i = 1; ; ++i ) {
sprintf( buf, "DELE %d\r\n", i );
if( send( s, buf, strlen( buf ), 0 ) == -1 ) {
perror( "Sending DELE" );
closesocket( s );
return 1;
}
if( recv( s, buf, 128, 0 ) == -1 ) {
perror( "Waiting for DELE answer" );
closesocket( s );
return 1;
}
if( strncmp( buf, "+OK", 3 ) != 0 )
break;
}
send( s, "QUIT\r\n", 6, 0 );
closesocket( s );
puts( "Done." );
return 0;
}
--------------------Configuration: popdel32 - Win32 Debug--------------------
Compiling...
popdel32.cpp
Linking...
popdel32.obj : error LNK2001: unresolved external symbol _recv@16
popdel32.obj : error LNK2001: unresolved external symbol _closesocket@4
popdel32.obj : error LNK2001: unresolved external symbol _send@16
popdel32.obj : error LNK2001: unresolved external symbol _connect@12
popdel32.obj : error LNK2001: unresolved external symbol _socket@12
popdel32.obj : error LNK2001: unresolved external symbol _htons@4
popdel32.obj : error LNK2001: unresolved external symbol _gethostbyname@4
popdel32.obj : error LNK2001: unresolved external symbol _WSAStartup@8
Debug/popdel32.exe : fatal error LNK1120: 8 unresolved externals
Error executing link.exe.
popdel32.exe - 9 error(s), 0 warning(s)
What causes this
-
-
why is visual c++ 6.0 giving me those errors while its linking?
look 2 posts up ^
-
lol indeed i read your post but i figured you were using visual c++.
your most probably a unix dude :)
But i can compile it with what ever. I have borland 5.5, devc++, visual 6.0, DJGPP, etc..
just tell me what to tweak to compile without error in any of win32 compilers hehe.
If we cant make it a win32 port then i can use the unix version and make a perl script execute it from the web and use it like that. that can do the same job. but a dos version would have been fun