Skip to main content

Questions tagged [ash]

The Almquist shell is a variant of the Bourne shell. Its most famous forks ares busybox ash and dash.

Filter by
Sorted by
Tagged with
0 votes
0 answers
48 views

Using ssh in a while read loop reading from stdin [duplicate]

I have a shell function that returns a list of hostnames and IP addresses: $ list_hosts hostA 10.1.1.1 hostB 10.1.1.2 hostC 10.1.1.3 I want to get a different address for each host: $ function ...
Tom's user avatar
  • 524
0 votes
3 answers
239 views

How to make 'adb shell' to read /etc/profile or other configuration files?

I am working on an embedded Linux system (kernel-5.10.24), and it uses ash from busybox as /bin/sh. The system support login from serial console and adb shell from PC. Now I found the shell started ...
wangt13's user avatar
  • 443
1 vote
0 answers
865 views

Merge set x (xtrace) and v (verbose)

How to merge set -x and set -v in ash? (or set -v with a prefix) In other words, echo back command upon running. The DEBUG signal does not exist in ash: DEBUG: invalid signal specification. set -x $ ...
wjwrpoyob's user avatar
  • 438
2 votes
1 answer
609 views

Stop stdin while command is running

How to stop stdin while command is running in ash (not bash)? For example: sleep 10 type echo hello while sleep is still running observe hello is in stdout after sleep finishes Desired: sleep 10 ...
wjwrpoyob's user avatar
  • 438
0 votes
3 answers
6k views

How to use sh script to send hex data to /dev/ttyUSB0?

I'm working with a paired down embedded Linux installation that does not support bash, only sh across a ssh terminal. I need to send hex data to a connected USB device /dev/ttyUSB0. I'm able to do ...
Jim Fell's user avatar
  • 265
0 votes
1 answer
1k views

alias in ash - limitation, syntax issue?

I'm running OpenWRT in a NAS (WD-MBL) and putting together a set of aliases to make maintenance easier via the command line. These work as expected: alias shutdown='sync && wait && ...
Groucho's user avatar
  • 31
0 votes
1 answer
252 views

ash - parse a config file line after line

My config file looks as follows: ver 3 file test1.conf ~/etc file test2.conf ~/etc/conf script tst.sh I'd like my script to iterate through all lines prefixed with "file", extract filename ...
Kal800's user avatar
  • 35
12 votes
2 answers
21k views

What is the difference between `ash` and `sh` shell on Linux?

I am new to a lot of tools on Linux. A quick search did not help, I only got more about bash or sh, and searching for it somehow leans towards bash in the search results. There are quite a few ...
questionto42's user avatar
1 vote
2 answers
1k views

ssh, start a specific shell (ash), and source your environment on the remote machine

This is a kind of follow-up question to this question: ssh, start a specific shell, and run a command on the remote machine?, except more-specifically regarding ash, and focused on the fact that ...
Gabriel Staples's user avatar
0 votes
3 answers
80 views

find/detect file name goups

On fs i have files like: PREFIX_GROUPNAME_OTHERNAMES[.txt|.*] eg: A_ABC_A.txt A_ABC_B.txt A_ABC_C.txt A_XYZ_A.txt A_XYZ_B.txt A_XYZ_C.txt For some futher tasks i want to get the group names. $# ...
f b's user avatar
  • 13
0 votes
1 answer
500 views

How to generate a string of concatenated key/value pairs in a script?

I need to build a string of --build-arg parameter using some key/value pairs (build.args file) in a busybox shell: script.sh #!/bin/sh one=$1 two=$2 shift while IFS= read -r line; do set "$@&...
user3142695's user avatar
  • 1,599
0 votes
0 answers
17 views

ASH scripting quotes in backticks works with echo but not with actual execution [duplicate]

I am creating a script for my router (running busybox). In my script I generate a command in a variable like nvram set option='value with spaces' but when it is executed it complains that arguments ...
ulvesked's user avatar
  • 101
5 votes
3 answers
1k views

What one should check when re writing bash conditions for sh or ash?

Sometime, it is not possible to have the luxury of bash on a system, but conditions are easier to make on bash compared to sh or ash, what one should verify to ensure condition won't break with ...
Zulgrib's user avatar
  • 984
1 vote
0 answers
215 views

chpasswd halts provision script to ask for password

I'm using BusyBox on alpine linux to provision an LXC container created with ProxMax. The script is below. The problem I am having is the following line halts the provision script and asks for a ...
BugHunterUK's user avatar
2 votes
0 answers
414 views

Trap on DEBUG signal for the ash and dash shells?

With the bash shell, you can install a trap on the synthetic DEBUG signal. This is useful and will execute your function or bit of code on every shell command. Not so in ash or dash. $ trap 'echo hi' ...
Ilias Karim's user avatar
1 vote
1 answer
3k views

Extracting data from a file using sed and regular expressions

I have a system running on Embedded Linux with BusyBox. There is a YAML configuration file 'cfg.yaml' which contains something like this: range: tcpportmin: 10000 tcpportmax: 20000 I need to ...
Snowjay's user avatar
  • 35
1 vote
1 answer
1k views

What happens to arguments passed to bash/ash functions?

This answer about -- gives a lot of good information about using -- in POSIX shells and this answer about passing all arguments to a script led to the following function: my_echo() { set -x ...
MrMas's user avatar
  • 295
2 votes
2 answers
2k views

Why does SIGTERM work to terminate bash but not ash or dash?

Comparing bash, ash and dash, only bash can be terminated by SIGTERM kill -TERM <pid> For ash and bash, I need SIGHUP or SIGKILL kill -HUP <pid> kill -KILL <pid> What's the ...
finefoot's user avatar
  • 3,132
0 votes
1 answer
2k views

How to find the value of a variable in ash?

I have a giant script that I'm attempting to debug, and in it it has the following construction: var "-p Some Parameter" || return 1 var "-p Other Parameter" || return 0 I want to know what it ...
Maxim's user avatar
  • 738
4 votes
1 answer
3k views

Where is the PS1 prompt variable set in ash shell?

I have a NAS drive from Western Digital. I can ssh into it, and when I log in, the first line that appears is: BusyBox v1.20.2 (2014-10-30 15:28:59 CST) built-in shell (ash) I don't like the default ...
osullic's user avatar
  • 235
7 votes
1 answer
9k views

How to persist environment variables in ash, the Almquist shell?

How can I get ash to load some environment variables on startup? Just put them in /etc/profile /etc/profile is only read for login shells; what about non-login shells, as frequently pop up when ...
DJV's user avatar
  • 71
0 votes
1 answer
296 views

busybox - Can't detect grub binaries

I compiled GRUB from source, using pretty much default settings in a chroot debian sid environment using default --prefix so it installed in /usr/local. When I copied the files over to a system with ...
Juan Ramirez's user avatar
8 votes
0 answers
10k views

Accessing regular linux commands in Huawei's Dopra Linux

Backstory: I have a Huawei HG8245 router in my house and I want to change the default username/password. I've tried following this guide but the config file always gets reset. My ISP isn't helping ...
Dzeri96's user avatar
  • 211
4 votes
2 answers
5k views

Split string in ash shell? (BusyBox)

I'm trying to split a string in ash shell using only the tools provided in BusyBox. The string is of the format host-name:port,host-name2:port2 but I only care about the first hostname and port, both ...
Hexodus's user avatar
  • 41
1 vote
3 answers
2k views

Echo Permission Denied (Trying to use echo instead of ls command in shell script)

I am trying to write a script and at some point i needed to list all the things in a directory and grep someting from that directory. I can't do it with ls. ls is not my guy to do it. So i tried to do ...
Ugur Akgul's user avatar
3 votes
1 answer
1k views

Getting error code of the first command in pipe in ash

I use wget to download a big file to two FIFOs like that: wget <wget-args> -O - | tee -a "$fifo1" >> "$fifo2" I want to retrieve the error code of wget on failure. set -o pipefail ...
K. Koovalsky's user avatar
2 votes
1 answer
2k views

Dash "-nt" behavior

The use case I can think of for -nt, would be updating a file if it is too old, or if it does not exist. Bash handles this just fine: $ bash -c 'touch 2.txt; sleep 1; touch 1.txt; [ 1.txt -nt 2.txt ];...
Zombo's user avatar
  • 1
0 votes
2 answers
13k views

How to check for command exit code inside if statement

I'm trying to return a 0 exit code if a command exit with the a code 143 (timeout, from the "timeout command"), 1 otherwise. Due to external constraint (CI script), I have to start the command and do ...
Dremor's user avatar
  • 500
1 vote
3 answers
2k views

How can I expand a list of letters/numbers in ash?

In busybox, the default shell is ash, so some familiar tricks in bash are not available. One thing I would like to do is expand a list of letters, like {a..z}, which would expand to a b c d e f g h i ...
Paul's user avatar
  • 371
2 votes
0 answers
3k views

.ash_history file is not created

I am using a login session in my ash machine. My problem is, when executing history command in ash shell, it returns 0. This is because the .ash_history is not created. I tried to triage the issue by ...
Karthick's user avatar
1 vote
2 answers
3k views

how to move cursor left and right in a router's busybox shell

my router runs asuswrt merlin. the /bin/sh is packaged in BusyBox v1.25.1 (2017-12-02 00:49:46 EST) multi-call binary. my question is how do I move my cursor one word left and right? with bash, i ...
JackyJohnson's user avatar
2 votes
2 answers
457 views

Better way to retrieve n-th (index) positional parameter value in `ash` then `eval echo \$$n`?

I'd wish the user to select a file from a numbered list on screen in a mkinitcpio busybox ash environment. The list needs to be filled/sorted from top to bottom and printed in columns, like: 1) 2017-...
Pro Backup's user avatar
  • 5,014
1 vote
1 answer
1k views

How to make mkinitcpio busybox ash to source /etc/profile?

Arch Linux /usr/lib/initcpio/busybox is owned by package mkinitcpio-busybox 1.27.2-1 and is configured low on features, for example CONFIG_FEATURE_USE_INITTAB is not set. In a custom initramfs, ...
Pro Backup's user avatar
  • 5,014
2 votes
3 answers
2k views

How to move all files matching a certain name to a new folder if the number of matching files is greater than 10?

I'm looking to create a script that when executed it will look at a directory and search for all files and then automatically discover the filename patterns to then move them based on additional logic ...
lukemk1's user avatar
  • 39
22 votes
5 answers
30k views

Set environment variable for subshell

I know that I can run a command with an environment variable like this: FOO=bar mycommand I know that I can run commands in a subshell like this: (firstcommand && secondcommand) But can I ...
AndreKR's user avatar
  • 1,110
0 votes
1 answer
522 views

ash - case insensitive

I am using the ash shell (on Busybox) and I want to make the tab completion case insensitive. "cd a" and Tab completes only all directories starting with a but ignore all directories which start with ...
musbach's user avatar
  • 321
25 votes
4 answers
19k views

How to port to bash-style arrays to ash?

Some time ago I have written a bash script which now should be able to run in environment with ash. In bash it was like : services=( "service1.service" "service2.service" ...
metamorphling's user avatar
1 vote
1 answer
454 views

Scripting with 'for' and grep/egrep

I'm trying to learn some more Linux, and from experience the best way is to try to bang your head against the wall. So now that I've done a task manually a few times I would like to automate it. This ...
Lars's user avatar
  • 13
2 votes
2 answers
2k views

How can i run a program with modified argv[0] using busybox ash shell?

In bash I would simply use exec -a. How can I do this in busybox? Is it even possible, or will I have to write my own C program to call exec(3) directly?
ali1234's user avatar
  • 1,124
2 votes
0 answers
753 views

ash: List functions

Does busybox ash have an equivalent to bash's: compgen -A function for listing the names of the declared functions? (Not a duplicate of dash: List declared functions: This is for ash, not dash).
Ole Tange's user avatar
  • 35.8k
-5 votes
1 answer
149 views

Is it possible to run GDrive with Bourne Shell or Almquist shell (sh or ash) on xiaomi smart ip camera? [closed]

I have an IP camera with the armv5tejl processor. My aim is to send videos from camera to GoogleDrive. I downloaded gdrive but it can be run only with bash. Is it possible to run gdrive somehow ...
Oleksandr's user avatar
  • 1,119
1 vote
1 answer
6k views

How do I find and list folders with a specific folder name, containing files modified recently?

I have a set of folders that are regularly updated, which I would like to regularly parse through and update to a simple text file list. This list gets used with rsync so I shorten the file names ...
neonfrontier's user avatar
4 votes
2 answers
4k views

Where to find the source code for the Almquist Shell?

I'm learning the Unix shell command language looking for a repository that contains the source code for the Almquist shell ("ash" / "dash") but I could not find it. Can you help me find the source? I'...
Niklas Rosencrantz's user avatar
1 vote
1 answer
365 views

Busybox ASH inside initrd has a problem when piping tee to sed

I'm trying to log the early boot output from the init script. This is what is working: mkdir -p /run/log && \ mkdir -p /tmp && \ mkfifo /tmp/stage-1-init.log.fifo1 && \ mkfifo ...
CMCDragonkai's user avatar
1 vote
2 answers
3k views

Automatically entering ssh password from Busybox terminal

I currently am attempting to reboot a modem via ssh using a bash script. For reasons I don't feel like explaining, I NEED to start on an ubuntu server computer, ssh into a setup running busybox 1.21.1 ...
wvu_evan12's user avatar
4 votes
1 answer
3k views

Start sh in a specified directory from inittab

I am currently working on an embedded Linux system. For it to be similar to our other products I need to have it start a shell in a specified directory on boot, accessible using the serial port. For ...
Dakkaron's user avatar
  • 2,057
0 votes
1 answer
1k views

Checking the schedule of a cronjob and doing a conditional check on specific parts

Edit: I managed to solve this myself, I actually deleted my original question as I was over complicating the process slightly, but have since answered it in case others find it useful. RegExp is not ...
James White's user avatar
11 votes
3 answers
12k views

RegExp testing with ash shell (BusyBox)

I need to do a RegExp pattern test on a certain bit of user input. This is the pattern I need to test the value against. ^([a-z]{2,3})\-([a-z][a-z]*[0-9]*)\-(\d+)$ An example match would be: na-...
James White's user avatar
2 votes
6 answers
9k views

How can I filter out a specific part of a JSON response in ash shell

I'm using wget with -qO to a specific updater URL for OpenELEC which provides the following JSON response, similar to the one below. {"data":{"update":"OpenELEC-RPi2.arm-5.0.8.tar","folder":"releases"...
James White's user avatar
0 votes
2 answers
4k views

ffmpeg batch convert .avi to .mp4 - in ash

I'm looking to batch-convert a directory (or several) of video files from .avi to .mp4 containers, just copying the video and audio streams across. I know the ffmpeg command to do this, and have no ...
Casey Bennetto's user avatar