neurobin / shc

Shell script compiler

Home Page:https://neurobin.org/projects/softwares/unix/shc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot execute shell scripts with functions

tejasrao97 opened this issue · comments

#!/bin/bash

total=0
count()
{
for i in $@; do
if [ ! -z "${i##[0-9]*}" ]; then
echo "Please enter numeric only"
exit 1
fi
total=$(($total + $i))
done

if [ $total -eq 0 ]; then
echo "Plesae execute script like: $0 10 20 30"
exit 0
fi

echo $total

}

count $@

how did you compile?

shc -T -f shell script file name

shell hangs when I run the complied binary and also getting an operation not permitted error when I run as ubuntu user:
ubuntu@instance: shc -f sam.sh -v
shc shll=sh
shc [-i]=-c
shc [-x]=exec '%s' "$@"
shc [-l]=
shc opts=
shc: cc sam.sh.x.c -o sam.sh.x
shc: strip sam.sh.x
shc: chmod go-r sam.sh.x
ubuntu@instance: ./sam.sh.x
./sam.sh.x: Operation not permitted
Killed
ubuntu@instance: sudo su
root@instance:/home/ubuntu# ./sam.sh.x
^C

use sudo to run the script.