uclinux中shell脚本执行错误 [英] shell script execution error in uclinux

查看:58
本文介绍了uclinux中shell脚本执行错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的shell脚本如下:

I have a simple shell script as follows:

myfunc()
{
        #print hello world
        echo "Hello World";
}

myfunc

当我在 linux pc 中执行该脚本时,该脚本运行良好,但是当我在 uclinux 中运行相同的脚本时,出现语法错误"的错误.问题的原因是什么?

The script works fine when I execute in linux pc but when I run the same in uclinux, I get the error as "syntax error". What could be reason for the problem?

以下代码适用于 uclinux:

The following code works in uclinux:

####\#!/bin/sh
echo "Hello World"

但是,以下代码不起作用:

But, the following code is not working:

####!/bin/sh
myfunc()
{
        #print hello world
        echo "Hello World";
}

myfunc

推荐答案

结果取决于您运行的 shell.大多数 uclinux 的 shell 实际上是指向 Busybox 的符号链接.Busybox 为不同的内存占用需求实现了各种微型外壳.我记得,只有ash 支持函数语法.检查您的 busybox 版本及其构建配置.

The result depends what shell you run. Most uclinux's shells are actually symbolic links to Busybox. Busybox implements various tiny shells for different memory foot print requirements. As I remember, only ash supports function syntax. Check your busybox version and its build config.

这篇关于uclinux中shell脚本执行错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆