I wrote Bash script and now I want to convert it to Ash. One headache is this function:
This function prints out the options and allows selection. First the ash error handler had me change the brackets as such
Which I think will be better. But now it is complaining about a missing "}" bracket.
When I get rid of the do statement, the error goes away. I tried adding a while before hand. It didn't make a difference so it's presently uncommented, and the code is bellow.
Does anybody know how I can change this to an 'ash' script successfully?
---------- Post updated at 06:17 PM ---------- Previous update was at 06:14 PM ----------
To summarize, I can't get the 'do' statement to work.
Last edited by Scrutinizer; 06-24-2014 at 03:48 AM..
Reason: CODE tags
I didn't have a "while" section to it when I was using Bash, and the command prompt just waited for me to enter a key. Now that I require the while statement, I don't know how to replicate that behavior.
I could do
But then the user needs to press enter to continue. That's not as nice.
Last edited by Scrutinizer; 06-24-2014 at 03:49 AM..
Reason: CODE tags
How do you make it so that, for the case statement, the user doesn't have to press 'enter'. I want it to be as soon as they press "1", for example, they're taken to that menu.
You could also do lots of tricky things with dd and stty, which might work more reliably. From this thread:
The reason this is more reliable is, if someone hits F1 and dumps \x1b[11~ into your terminal, that'd be one keystroke with inkey() and five keystrokes with read -n.
Also, inkey times out eventually, leaving "char" blank if nothing was typed. The timeout is in tenths of a second, for 1 second it'd be "time 10" for example.
If you gave it an infinite timeout, it might start waiting for entire lines again, terminals are tricky like that.
It works in ash for me, though it mostly depends on whether whatever embedded thing you're using has stty.
Last edited by Corona688; 06-26-2014 at 11:53 PM..
hello everybody,
i'm a beginner in ash and i want to convert this bash script to ash.
this script send a xml file to a nagios server :
#!/bin/bash
PROGNAME=$(basename $0)
RELEASE="Revision 0.3"
print_release() {
echo "$RELEASE"
}
print_usage() {
echo ""
echo "$PROGNAME... (6 Replies)
I'm trying to convert this working bash script into an Ash script,
read -p "Username:" _username
if ! ]]; then
echo "Valid"
else
echo "INVALID"
fi
However, Ash does not recognize the "=~" character.
How can I do this?
Also, is there a good reference guide, so I... (5 Replies)
Hi All,
I have a script that I wrote on a bash shell, I use it to sort files from a directory into various other directories. I have an variable set, which is an array of strings, I then check each file against the array and if it is in there the script sorts it into the correct folder.
But... (5 Replies)
I'm working on a script that will search through a directory for MKV files and remux them to MP4. I found a few other scripts around the net that do this, but they all have limitations that don't always get the job done. The main limitation I've found is that most scripts look for the video track... (2 Replies)
Guys
I now have a script that's working in a BASH environment, however one line doesn't appear to be working on an embedded device that has a busybox therefore ASH shell. I've googled but there's very little I can find regarding the ASH shell.
In BASH the following line works...
if ] ;... (6 Replies)
Hello everyone,
I got this type of error when programming in bash
new.bat: 16: cannot create : Directory nonexistent
$bool
new.bat: 37: Syntax error: "then" unexpected (expecting "fi")
Does anyone know why?
Here is my code
#!bin/bash
#function helps(){... (4 Replies)
Hi,
For my bash script, terminal with bash is generate an OK output and program works right.
already,
terminal with ash have "line 48: syntax error: Bad substitution" output and program don't work.
:confused: (0 Replies)
Hi all, dummy here.... I have major errors on entering the shell. On login I get:
-bash: dircolors: command not found
-bash: tr: command not found
-bash: fgrep: command not found
-bash: grep: command not found
-bash: grep: command not found
-bash: id: command not found
-bash: [: =: unary... (12 Replies)
Hi all, I have major errors on entering the shell. On login I get:
-bash: dircolors: command not found
-bash: tr: command not found
-bash: fgrep: command not found
-bash: grep: command not found
-bash: grep: command not found
-bash: id: command not found
-bash: #
root@host # pwd
/bin... (0 Replies)