Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [ash]

The Almquist shell is a variant of the [tag:bourne-shell]. Its most famous forks ares [tag:busybox] ash and [tag:dash].

3
votes
1answer
58 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 ...
1
vote
1answer
97 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 ...
0
votes
1answer
32 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 ...
4
votes
0answers
808 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 ...
0
votes
1answer
227 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 ...
0
votes
3answers
177 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 ...
2
votes
1answer
152 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 ...
2
votes
1answer
171 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 ];...
0
votes
2answers
1k 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 ...
0
votes
1answer
143 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 ...
1
vote
0answers
672 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 ...
1
vote
1answer
406 views

how to move cursor left and right in default 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 ...
1
vote
1answer
108 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-...
1
vote
1answer
271 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, ...
2
votes
3answers
192 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 ...
0
votes
0answers
669 views

Keep telnet connection open in background and send output to file

Some background: Working with ash shell (busybox) on an embedded device. From a script, I need to keep a local telnet connection open in the background to monitor the output of a service running ...
3
votes
3answers
3k 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 ...
0
votes
1answer
115 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 ...
8
votes
3answers
4k 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" ...
1
vote
1answer
238 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 ...
2
votes
2answers
536 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?
0
votes
0answers
271 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).
-6
votes
1answer
124 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 ...
1
vote
1answer
3k 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 ...
1
vote
2answers
2k 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'...
1
vote
1answer
224 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 ...
1
vote
2answers
1k 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 ...
3
votes
1answer
2k 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 ...
0
votes
1answer
349 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 ...
5
votes
3answers
5k 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-...
0
votes
6answers
2k 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"...
0
votes
2answers
2k 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 ...
21
votes
2answers
11k views

Ash profile/configuration file

I am looking for a way to customize Ash sessions with my own sets of aliases and whatnots. What is the Ash equivalent of Bash's bashrc files?
4
votes
1answer
1k views

History in the Almquist shell in the NetBSD

In NetBSD /bin/sh is a modified version of the Almquist shell. With the command fc -l it is possible to view the last 16 commands typed in the prompt in the current session and not the older ones. ...
16
votes
1answer
1k views

Percent in $PATH environment variable

My $PATH looks like this: /home/torbjorr/deployed/vector/x86_64-GNU%2fLinux:/home/torbjorr/deployed/typewriter/x86_64-GNU%2fLinux:/home/torbjorr/deployed/mustudio/x86_64-GNU%2fLinux:/home/torbjorr/...
2
votes
1answer
940 views

Regex doesn't work with grep

I have a string like this TEST="/dev/sda1 on /media/sda1 type vfat (rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,quiet)" (Result from mount | grep sda1) ...
1
vote
1answer
7k views

How to write simple if condition in ash?

I would like to write a small script that would check every once in a while if I have the internet connection. I would like to run it in crontab on my router where I have ash. I am having a hard ...
4
votes
1answer
3k views

Number comparisons in BusyBox ash [closed]

I have the following script that extracts data from the EXIF command on my busybox ash-based system. I parse the date tag from the end of the file and use case as a final check to ensure the format ...
2
votes
2answers
2k views

Busybox ash script does not exit cleanly after executing cat; unable to get exit code

Consider the following script wrapcat.sh (a wrapper for cat) for illustrative purposes. It is run with busybox (ash) in an embedded Linux 2.6 box. #!/bin/sh cat $1 Under certain circumstances, this ...
2
votes
1answer
4k views

Using BASH versus ASH on Synology

The majority of my photo files have the following naming convention / format IMG_20131204_120000.JPG, showing date and time the photo was taken (iPhone/Apple naming convention). However, not all my ...
4
votes
1answer
2k views

urlencode function

I need a way to URL encode strings with a shell script on a OpenWRT device running old version of busybox. Right now I ended up with the following code: urlencode() { echo "$@" | awk -v ORS="" '{ ...
15
votes
2answers
10k views

Are dash, ash and sh script 100% compatible?

I wanted to know whether scripts written for dash, ash, and sh are 100% compatible? Are there any added features to dash or ash, or syntax change? From what I heard, ash is a direct descendant of sh....
0
votes
2answers
5k views

Why does this incrementing for loop return a bad variable?

I'm trying to call this shell script from within the CLI of GRASS GIS: for (( day=5; day<367; day+5 )); do # commands that I've tested without a loop. done exit 0 returns Syntax error: Bad for ...
37
votes
1answer
2k views

Avoiding “BASH-isms” in shell scripts

Does there exist a tool similar to Perl::Critic that will inspect your shell scripts and point out flaws, portability issues, uses of non-standard programs without fallbacks, depreciated program uses, ...