Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web services 使用自定义telnet/SSH外壳创建Web服务原型_Web Services_Ssh_Prototype_Telnet - Fatal编程技术网

Web services 使用自定义telnet/SSH外壳创建Web服务原型

Web services 使用自定义telnet/SSH外壳创建Web服务原型,web-services,ssh,prototype,telnet,Web Services,Ssh,Prototype,Telnet,我正在寻找一个web服务原型,而不必处理HTTP和其他令人头痛的web问题,这样用户就可以登录一个只使用stdin和stdout的简单程序并与之交互 经过一些研究,我意识到,“shell”就是这样做的,所以我决定创建一个特定的用户并将其shell设置到我的程序中,我可以很容易地原型化这种“webservice”,甚至可能允许许多不同的用户在程序本身内部进行身份验证,并且都使用相同的ssh用户 以下是此类服务的一个示例,以测试这一想法: #include <stdio.h> lon

我正在寻找一个web服务原型,而不必处理HTTP和其他令人头痛的web问题,这样用户就可以登录一个只使用stdin和stdout的简单程序并与之交互

经过一些研究,我意识到,“shell”就是这样做的,所以我决定创建一个特定的用户并将其shell设置到我的程序中,我可以很容易地原型化这种“webservice”,甚至可能允许许多不同的用户在程序本身内部进行身份验证,并且都使用相同的ssh用户

以下是此类服务的一个示例,以测试这一想法:


#include <stdio.h>

long fibonacci(int n){
   long a = 0;
   long b = 1;
   for(int i=0; i<n; ++i){
       if(i%2) a += b;
       else    b += a; 
       if(a<0 || b<0) return -1;
   }
   return (long[]){a, b}[n%2];
}

int main(int argc, char * argv[]){
   char line[1024];

   int x;
   printf("Welcome to the fibonacci shell.\n");
   printf("Type an integer n, and I will tell you the nth fibonacci number.\n");
   while(1){
       printf("> ");
       if(fgets(line, sizeof line, stdin) <= 0) break;
       int result = sscanf(line, "%d", &x);
       if(result <= 0){
           printf("fibshell: Please type a number.\n"); }
       else{
           printf("fib(%d) = %ld\n", x, fibonacci(x)); }
   }

   return 0;
}

#包括
长斐波那契(整数n){
长a=0;
长b=1;
对于(int i=0;i