You are not logged in.
Ok, so I've been staring at this script for the past hour with no avail. Basically, I want to pass arguments to a C program I wrote, both with arguments of the bash script and variables calculated in the bash script. For some reason it's not working, here's the script where it is right now:
#!/bin/bash
# Wrapper script for finding modes, outputting data as Frequency vs Amplitude
NUMPOS=$(cat $1 | awk '/^position/' | wc -l)
LINES=$[$(cat $1 | wc -l)-5-$NUMPOS]
NUMFREQ=$[$LINES/$NUMPOS]
mkdir split_$1
cp -t split_$1 drumdata $1
cd split_$1
./drumdata $1 $NUMPOS $NUMFREQ
rm drumdata $1
This gives me the error: ./getModes.sh: line 19: 26946 Segmentation fault ./drumdata $1 $NUMPOS $NUMFREQ
So I tried a different method with array variables
#!/bin/bash
# Wrapper script for finding modes, outputting data as Frequency vs Amplitude
NUMPOS=$(cat $1 | awk '/^position/' | wc -l)
LINES=$[$(cat $1 | wc -l)-5-$NUMPOS]
NUMFREQ=$[$LINES/$NUMPOS]
args[0]=$1
args[1]=$NUMPOS
args[2]=$NUMFREQ
mkdir split_$1
cp -t split_$1 drumdata $1
cd split_$1
./drumdata ${args[@]}
rm drumdata $1
Which gives me the error: ./testModes: line 22: 7945 Segmentation fault ./drumdata "${args[@]}"
Which makes me want to cry because I wrote a script to test array variable behavior:
File Edit Options Buffers Tools Sh-Script Help
#!/bin/bash
args[0]=test
args[1]=getModes.sh
args[2]=drumdata.c
cp -t asdf ${args[@]}
And it works . Why aren't my variables being evaluated?
Offline
Moved to General Programming.
Offline