`
ncs478yl
  • 浏览: 30230 次
社区版块
存档分类
最新评论

sco unix ftp 源代码

阅读更多

sco unix ftp 源代码
2012年01月08日
  sco unix ftp 源代码如下代码可以实现 unix to unix 的文件发送,但不通实现unix to windows之间的发送,各位指点指点。
  #include ;
  #include ;
  #define NORMAL0
  #define ABNORMAL 1
  #define ON 1
  #define OFF 0
  main (argc, argv)
  int argc;
  char *argv[];
  {
  FTPINFO ftpinfo; 
  void usage(), check_n_close();
  char *progname;
  char *host;
  progname = (char *) argv;
  if ( argc error: ftp_prconnect failed.\n"); 
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * send user name to the remote server.
  */
  if (ftp_user( &ftpinfo, "bank" ) error: ftp_user failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * send user password to the remote server.
  */
  if (ftp_passwd ( &ftpinfo, "" ) error: ftp_passwd failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  } 
  /*
  * set the idle time for this connection.
  */
  if (ftp_idle ( &ftpinfo, "7200" ) error: ftp_idle failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * do a 'cd' on the remote ftp server.
  */
  if (ftp_chdir( &ftpinfo, "winnt" ) error: ftp_chdir failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * do a 'pwd' on the remote ftp server.
  */
  if (ftp_pwd ( &ftpinfo ) error: ftp_pwd failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * set transfer mode to ascii.
  */
  if (ftp_ascii ( &ftpinfo ) error: ftp_ascii failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * set transfer mode to binary.
  */
  if (ftp_binary ( &ftpinfo ) error: ftp_binary failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * set transfer mode back to ascii - using ftp_settype.
  */
  if (ftp_settype ( &ftpinfo, ASCII ) error: ftp_settype failed in ascii mode.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * set transfer mode back to binary - using ftp_settype.
  */
  if (ftp_settype ( &ftpinfo, BINARY ) error: ftp_settype failed in binary mode.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * make a directory under /tmp on the server.
  */
  if (ftp_mkdir ( &ftpinfo, "prem" ) error: ftp_mkdir failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * change the mode of the directory created above.
  */
  if (ftp_site ( &ftpinfo, "chmod 775 prem" ) error: ftp_site failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * remove the directory created above.
  */
  if (ftp_rmdir ( &ftpinfo, "prem" ) error: ftp_rmdir failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * quit the FTP session decently.
  */
  if (ftp_bye( &ftpinfo ) error: ftp_bye failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * use ftp_login to login into the remote ftp server and quit.
  */
  if (ftp_login ( &ftpinfo, host, "bank", "", NULL ) error: ftp_login failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * do a 'put' to the remote host.
  */
  if (ftp_putfile ( &ftpinfo, "/tmp/passwd", "c:/passwd" ) error: ftp_putfile failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  else {
  printf("transfer speed: \n");
  printf("\t\tbytes transferred = %ld\n",
  ftpinfo.speed.size_bytes);
  printf("\t\ttime taken = %.2g seconds\n",
  ftpinfo.speed.seconds); 
  printf("\t\trate = %.2g Kbytes/s\n",
  ftpinfo.speed.kbs);
  }
  /*
  * set transfer mode back to ascii - using ftp_settype.
  */
  if (ftp_settype ( &ftpinfo, ASCII ) error: ftp_settype failed in ascii mode.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * do a 'get' from the remote host.
  */
  if (ftp_getfile ( &ftpinfo, "/tmp/passwd","c:/passwd" )error: ftp_getfile failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  else {
  printf("transfer speed: \n");
  printf("\t\tbytes transferred = %ld\n",
  ftpinfo.speed.size_bytes);
  printf("\t\ttime taken = %.2g seconds\n",
  ftpinfo.speed.seconds); 
  printf("\t\trate = %.2g Kbytes/s\n",
  ftpinfo.speed.kbs);
  }
  /*
  * list /tmp on remote host to file /tmp/test.
  */
  if (ftp_dir ( &ftpinfo, "/tmp", "/tmp/test" ) error: ftp_dir failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * list /tmp on remote host to stdout.
  */
  if (ftp_dir ( &ftpinfo, "/tmp", NULL ) error: ftp_dir failed to write to stdout.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * delete the file on the remote host.
  */
  if (ftp_del ( &ftpinfo, "/tmp/asciifile" ) error: ftp_del failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * quit the FTP sessions decen
  关于DNS的负载均衡的问题 tly.
  */
  if (ftp_bye( &ftpinfo ) error: ftp_bye failed.\n");
  (void) check_n_close ( &ftpinfo, ABNORMAL );
  }
  /*
  * we're done with our job...so exit the program gracefully.
  */
  (void) check_n_close ( &ftpinfo, NORMAL ); 
  }
  void
  usage(progname)
  char *progname;
  {
  printf("usage: %s ;\n", progname);
  exit (1);
  }
  void
  check_n_close ( ftpinfo, status )
  FTPINFO *ftpinfo;
  int status;
  {
  if (ftpinfo ->; sockfd >;= 0)
  close (ftpinfo ->; sockfd);
  if (status == ABNORMAL)
  printf("error: %s\n", ftpinfo ->; ftp_msg);
  else
  printf("success: %s\n", ftpinfo ->; ftp_msg);
  printf("final reply from server: %d\n", ftpinfo ->; reply);
  fflush ( stdout );
  exit (status);
  }sco unix ftp 源代码oksco unix ftp 源代码怎么样编译。sco unix ftp 源代码ccprog.c -o prog -lftpsco unix ftp 源代码加为精华吧sco unix ftp 源代码难道没有人作过吗?sco unix ftp 源代码我没用过ftp库函数,用普通socket函数到是写过,
  效果还不错,一直在用!sco unix ftp 源代码请问老大, 我的机器怎么有一个提示/usr/lib/libftp.a 的提示呀http://www.hld1001.com!暖奶器
  编译没有其他的错误,希望指点一二,谢谢!sco unix ftp 源代码各位老大:编译的问题解决了,命令如下:cc -o ftp ftp.c -llftp -lsocket
  可是运行时出现错误如下:
  error: fopen failed to open in "r" mode for sending
  final reply from server: 150
  或
  error: ftp _ftpfile failed
  ferror:data connection failed
  inal reply from server: 553
  那位能帮我解决!这里先行谢过了!sco unix ftp 源代码man ftp看到最后就是上面的例程了,只有unixware下能够使用,必须链接libftp.a,其他系统用不了的。
  
  
  
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics