Question

I'm sure this is simple but I just don't know how to do it...

I have a script for busybox on an embedded system which I would like to run but I don't know how to run a script

I can log in to busybox and type a few commands but that's the limit of my knowledge, how do I execute a script that I have in .txt format on my desktop?

Was it helpful?

Solution

Two ways I can think of:

  • The boring but more portable one:

    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.

  • The proper way:

    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.

Without more information on your embedded device and the script we cannot really help you more.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top