-ash: ./test.sh: not found

本文介绍在Linux环境下,如何将脚本中的#!/bin/bash修改为#!/bin/sh,解决因未安装bash shell而引起的问题。

进入人间中把#!/bin/bash修改为#!/bin/sh,因为linux没有安装bash shell

root@ER7212PC:/lib/preinit# ./test.sh /bin/ash: ./test.sh: Permission denied root@ER7212PC:/lib/preinit# chmod +x test.sh root@ER7212PC:/lib/preinit# ./test.sh /bin/ash: ./test.sh: not found root@ER7212PC:/lib/preinit# . /test.sh /bin/ash: .: can't open '/test.sh': No such file or directory root@ER7212PC:/lib/preinit# ls 02_default_set_state 10_indicate_failsafe 50_indicate_regular_preinit 99_10_run_init 03_preinit_do_ramips.sh 10_indicate_preinit 70_initramfs_test 99_controller_preinit 05_set_preinit_iface 30_failsafe_wait 80_mount_root 99_insmod_switch_driver 06_set_rps_sock_flow 40_run_failsafe_hook 99_10_failsafe_login test.sh root@ER7212PC:/lib/preinit# ./test.sh /bin/ash: ./test.sh: not found root@ER7212PC:/lib/preinit# vi test.sh root@ER7212PC:/lib/preinit# cat test.sh #!/bin/bash # 设置目标文件路径 TARGET_FILE="/opt/tplink/EAPController/data/db/WiredTiger.wt" # 检查文件是否存在 if [ ! -f "$TARGET_FILE" ]; then echo "Error: File $TARGET_FILE does not exist." exit 1 fi # 获取文件的完整时间信息(模拟 ls --full-time) ori_time=$(ls --full-time "$TARGET_FILE") # 提取年、月、日、时间 year=$(echo "$ori_time" | awk '{print substr($7,1,4)}') month=$(echo "$ori_time" | awk '{print substr($7,6,2)}') day=$(echo "$ori_time" | awk '{print substr($7,9,2)}') time=$(echo "$ori_time" | awk '{print $8}') # 拼接时间格式 formatted_time="$year-$month-$day $time" # 输出结果 echo "Original ls output: $ori_time" echo "Extracted year: $year" echo "Extracted month: $month" echo "Extracted day: $day" echo "Extracted time: $time" echo "Formatted time: $formatted_time" # 模拟设置时间(避免真实修改) echo "Would execute: date -s \"$formatted_time\"" root@ER7212PC:/lib/preinit#
11-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值