我相信这很简单,但我只是不知道该怎么做。
我有一个嵌入式系统上busybox的脚本,我想运行它,但我不知道如何运行脚本
我可以登录busybox并输入一些命令,但这是我知识的极限,我如何在桌面上执行.txt格式的脚本?
发布于 2011-01-29 10:36:19
我可以想到两种方式:
1. Open the script file in an editor.
2. Log in to your embedded system and get to a busybox shell prompt.
3. Copy the first line of the script from the editor.
4. Paste it to the busybox prompt and press Enter, if necessary.
5. Copy the next script line from the editor
6. Paste it to the busybox prompt and press Enter, if necessary.
7. If there are any more lines, go back to step 5. If you encounter any errors, of course, you should stop and try to find out what's going on.
8. You will be tempted to just copy and paste the whole script in one go. _Don't!_ Depending of the TTY buffering behaviour on your embedded system, the results could be unexpected.
正确的方式:
1. Make sure that you have a writable filesystem for your script. Most embedded systems have at least a ramdisk that can be modified, although any changes are lost after rebooting. Once you find such a filesystem, `cd` into it if necessary.
2. Find a way to transfer the script file e.g. `script.txt` to your system. Depending on your embedded system, you could upload it using FTP, TFTP or SMB. If none of these is available, you can try using `cat` on busybox e.g. `$ cat > script.txt`, and copy/paste the script into the terminal - press `Ctrl + D` at the end of the file.
3. Run the script: `$ sh script.txt`
4. Alternatively to step `3`, use `chmod` to make the file executable: `$ chmod +x script.txt`. _Then_ you can run it: `$ ./script.txt`.
如果没有关于你的嵌入式设备和脚本的更多信息,我们不能真正帮助你更多。
https://stackoverflow.com/questions/4834607
复制相似问题