Sample Header Ad - 728x90

alias in ash - limitation, syntax issue?

0 votes
1 answer
1866 views
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 && sudo hdparm -Y /dev/sda && wait && sudo halt'
Shuts down the NAS gracefully.
daemon='sudo /etc/init.d/rsyncd status'
Tells me the rsync daemon's status.
drivechk='sudo dmesg | grep -i ext4-fs | grep -i sda'
Alerts me to filesystem issues caused by a bad shutdown requiring e2fsck.
tempchk='sudo smartctl -d ata -A /dev/sda | grep Temperature | cut -c 5-8,87-89'
Tells me the drive temperature. But there is one which I have not been able to get to work: fschk='df -h | grep -vE '^Filesystem|/dev/root|tmpfs'| awk '{ print $5 " " $1}' The stanza run from the command line works as expected:
~$ df -h | grep -vE '^Filesystem|/dev/root|tmpfs'| awk '{ print $5 " " $1}'
53% /dev/sda1
37% /dev/sda3
~$
If I add this to the /etc/profile.d/custom.sh file, log out and log in again I get this on the terminal:
~$ ssh user@192.168.1.3
--- snip ---
BusyBox v1.33.2 (2022-02-16 20:29:10 UTC) built-in shell (ash)

alias:  }' not found

~$
If I then run the alias I get this:
~$ fschk
>
If I query the alias list from the command line, I see that the one I added is shown differnetly in the printout:
~$ alias
--- snip ---
fschk='df -h|grep -vE '"'"'^/dev/root|tmpfs'"'"'|awk '"'"'{print  '
--- snip ---
:~$
But not in the file where it remains as I typed it:
~$ cat /etc/profile.d/custom.sh
--- snip ---
alias fschk="df -h|grep -vE '^/dev/root|tmpfs'|awk '{print $5 " " $1}'"
--- snip ---
~$
It seems that ash has a different/reduced version of alias but I cannot figure this one out. Any pointers will be greatly appreciated. Thanks in advance. Best, PCL
Asked by Groucho (31 rep)
May 8, 2022, 07:10 PM
Last activity: May 8, 2022, 07:40 PM