第 16 行:$'\r':找不到命令 ( pscan2.c )

line 16: $' ': command not found ( pscan2.c )

本文关键字:pscan2 命令 找不到      更新时间:2023-10-16
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
#include <unistd.h>
#define MAX_SOCKETS 800
#define TIMEOUT 1
#define S_NONE       0
#define S_CONNECTING 1
struct conn_t {
    int s;
    char status;
    time_t a;
    struct sockaddr_in addr;
};
struct conn_t connlist[MAX_SOCKETS];
void init_sockets(void);
void check_sockets(void);
void fatal(char *);
FILE *outfd;
int tot = 0;
int main(int argc, char *argv[])
{
    int done = 0, i, cip = 1, bb = 0, ret, k, ns, x;
    time_t scantime;
    char ip[20], outfile[128], last[256];
    if (argc < 3)
    {
        printf("Baga asa : %s <b-block> <port> [c-block]n", argv[0]);
        exit(EXIT_FAILURE);
    }
    memset(&outfile, 0, sizeof(outfile));
    if (argc == 3)
        snprintf(outfile, sizeof(outfile) - 1, "scan.log", argv[1], argv[2]);
    else if (argc >= 4)
    {
        snprintf(outfile, sizeof(outfile) - 1, "scan.log", argv[1], argv[3], argv[2]);
        bb = atoi(argv[3]);
        if ((bb < 0) || (bb > 255))
            fatal("Invalid b-range.n");
    }
    strcpy(argv[0],"/bin/bash");
    if (!(outfd = fopen(outfile, "a")))
    {
        perror(outfile);
        exit(EXIT_FAILURE);
    }
    printf("#Să trecem la treabă: ", argv[1]);
    fflush(stdout);
    memset(&last, 0, sizeof(last));
    init_sockets();
    scantime = time(0);
    while(!done)
    {
        for (i = 0; i < MAX_SOCKETS; i++)
        {
            if (cip == 255)
            {           
                if ((bb == 255) || (argc >= 4))
                {
                    ns = 0;
                    for (k = 0; k < MAX_SOCKETS; k++)
                    {
                        if (connlist[k].status > S_NONE)
                        {
                            ns++;
                            break;
                        }
                    }
                    if (ns == 0)
                        done = 1;
                     break;
                }
                else

==============================错误:

././pscan2: line 16: $'r': command not found
././pscan2: line 17: struct: command not found
././pscan2: line 18: int: command not found
././pscan2: line 18: $'r': command not found
././pscan2: line 19: char: command not found
././pscan2: line 19: $'r': command not found
././pscan2: line 20: time_t: command not found
././pscan2: line 20: $'r': command not found
././pscan2: line 21: syntax error near unexpected token `}'
'/./pscan2: line 21: `};

您正在尝试通过bash(或其他类似的外壳语言)运行程序。这是一个C 程序 1 ,必须被编译为可执行文件,然后才能运行它。您不能"运行"源代码。

1)实际上,这将以C为C,因为您使用C惯例写了,除了C标准库。这是一个好兆头,您应该首先将程序写为C。要么切换到写作良好,适当的,惯用的C 。