Questions tagged [ash]

A shell(ash) written by Kenneth Almquist and released to the comp.sources.unix Usenet news group on May 30th 1989. It has features similar to the Bourne shell(sh). Its many derivatives include the system shell on; Debian (dash), FreeBSD (sh), NetBSD (sh) and the default shell in Busybox (ash).

189 questions
0
votes
7 answers

How to extract a part of string?

I have string contains a path string="toto.titi.1.tata.2.abc.def" I want to extract the substring which is situated after toto.titi.1.tata.2.. but 1 and 2 here are examples and could be other numbers. In general: I want to extract the substring…
MOHAMED
  • 41,599
  • 58
  • 163
  • 268
0
votes
1 answer

Piping to a command in Ash Shell

I wrote a bash script to send an email using telnet. I'm installing it on a TS-7260 running busyBox (which has an ash shell). Something is different between Bash and Ash and I can't figure out why the following won't work. It's got to be something…
Narrat1ve
  • 35
  • 1
  • 8
0
votes
1 answer

Ash script - detect whether a variable equals to "?"

I am writing an Ash script and trying to detect whether an input variable equals to "?" or not. I found out that it is best to use case for doing this, but I can't manage to get this working. My code is: case $@ in *?*) usage operationSucceeded …
ThePiachu
  • 8,695
  • 17
  • 65
  • 94
0
votes
1 answer

How to check for extra parameters in ash script?

I have an ash script where I need to check whether the user has entered anything stupid. The proper use is: script -s [-f filter] [-n number] And I need to detect if user has for example evoked it like: script read…
ThePiachu
  • 8,695
  • 17
  • 65
  • 94
0
votes
1 answer

Ash pidfile showing wrong process id

I've got a really simple wrapper script to start a ruby program that monitors a network connection. The script's on router - hence we're using ash, not bash. Since we're using monit to monitor the status, I need a PID file. The problem is, the…
simonmorley
  • 2,810
  • 4
  • 30
  • 61
0
votes
1 answer

How can I have variable redirection in a shell script?

If I have a script with the command echo xx 2>&1 >junk I get a file with "xx" in it. If I have a script with R="2>&1 >junk" echo xx $R the script prints "xx 2>&1 >junk", instead of creating the file I desire. How can I have a redirection that is…
rich
  • 425
  • 3
  • 17
0
votes
1 answer

Unexpected redirection while parsing string

I have a string that parses files. But when i execute it. It gives an error. Here is the code; config="/tmp/files.config" tftp $TFTP_SERVER_IP -c get "files.config" "$config" while read line do IFS='=' read -a current_line <<< "$line" tftp…
Alperen Elhan
  • 402
  • 3
  • 6
  • 15
0
votes
1 answer

How to get variable from other while loop?

#!/bin/bash read() { count=0 cat localfile | while read line do FILE[$((count += 1))]="$line" done } read for((i=0;i<${#FILE[@]});i++) do echo ${FILE[i]} done The result of echo is whole blank. Is there any way to…
0
votes
1 answer

ASH if statement in a if statement

I've seen many examples with multiple conditions related to each other, but there are 2 different unrelated conditions where the second one only should happen if the first one is true. How can I get the following nicely organised and in 1…
Nixx
  • 15
  • 1
  • 7
0
votes
2 answers

Generate color fades via (B)ASH

I have a linux/bash script that sends multiple RGB color fades to multiple light. Every light can have it's own color but all colors should use the same amount of time to fade in/out. So it sends out a sequence of 3 differently targeted value-ranges…
Nixx
  • 15
  • 1
  • 7
0
votes
1 answer

BusyBox - syntax error: unexpected redirection

I'm on OpenWRT (which uses BusyBox). When I run this script: while read oldIP ; do iptables -t nat -D PREROUTING --dst $oldIP -p tcp --dport 443 -j DNAT --to 192.168.2.1:443 done < <(comm -23 <(sort /tmp/currentIPs) <(sort /tmp/newIPs)) I get…
exvance
  • 1,339
  • 4
  • 13
  • 31
0
votes
2 answers

Can I use simply exitcode within test expression (without $?)?

I have to make a conditional in ash, that depends on result of two commands. The problem is one of them returns the result to stdout, the other as exitcode. Do I have to write command2 RET=$? if [ `command1` -eq 1 -a $RET -eq 2 ] ; then ... or…
SF.
  • 13,549
  • 14
  • 71
  • 107
-1
votes
1 answer

Make this line table more simple

im still newbie at bash/ash ,can make this sysinfo more simple # display info machine_model=$(cat /proc/device-tree/model | tr -d "\000") echo " ──────────────────────────────────────────────────" printf " ====D-Net Gateway Link…
AjieD
  • 1
-1
votes
1 answer

docker sh vs bash variable ${@} expansion - ${@} doesn't work in sh

It's really straightforward: I am trying to build a docker image where the entrypoint receives the args passed. When I use a bash shell, it works. When I use sh which comes with alpine it doesn't expand; and I think it's because sh takes no args at…
Christian Bongiorno
  • 5,150
  • 3
  • 38
  • 76
-1
votes
2 answers

Linux Ash Shell script to check if certain package is installed & called via docker

I'm trying to run docker on embedded Linux running OpenWRT. Since the embedded Linux is a "resource constraint" I don't want Docker to install already installed packages, therefore I want to call a custom shell script with docker: RUN $CMD_STRING =…
cyber101
  • 2,822
  • 14
  • 50
  • 93
1 2 3
12
13