首页 > 解决方案 > c 中的 shell 程序运行但给出“lsh:没有这样的文件或目录。”

问题描述

#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define read_buffsize 1024
#define split_buffsize 64
#define delimiters "\t\r\n\a"
int main();
void loop(void);
char *readLine(void);
char **splitLine(char *command);
int start(char** args);
int execute(char **args);

我正在尝试用c制作一个shell程序。程序运行,但是当我输入命令并执行时,它显示“lsh:没有这样的文件或目录”。我把我的函数声明放在他的问题中只是因为我的代码大约有 150 行代码。示例输出如下所示:

> ls -l
lsh: No such file or directory
> pwd
lsh: No such file or directory
> 

标签: c

解决方案


也许您没有安装该程序lsh。但是lsh是SSH协议的一种实现。这是维基百科的说明。我认为这lsh甚至不能替代bashor sh。它仅用于登录远程计算机。因此lsh不知道如何执行它(如果你安装了它)。尝试使可执行字符串(或#definebash不是lsh


推荐阅读