Can't call a script from within a script

129 views Asked by At

I am trying to call a script from within another script. The idea is that the program should take in email that is sent to it directly from unix mail as stdin, and then parse some stuff out and send it to a new script.

I am having trouble reaching the new script. However, this problem only occurs when the script is accepting the email directly. If I cat a file into it, there is no problem and it finds the new script.

IE: if i have a test file called "email.txt" and i do the command:

cat email.txt | ./receiveEmail.sh

then the script calling works fine.

but if receiveEmail.sh receives the email directly, it fails to call the new script. I know this is the point where it fails because I get logs that the script is working all the way up to where it tries to call the new script.

--------receiveEmail.sh----------
#!/bin/bash
###do some stuff to parse the stdin coming in and get variable $subject and $body

issue=`. /home/dlaf/bin/makeissue.sh` ->>>> this is the line that doesn't seem to work when the input is straight from the email rather than from a txt file i send it.

I am confused why. I think it might be because I am missing some part of the path? Maybe the email coming in has no idea what my full path actually is? Im not sure though because when I type in to the command line echo $LD_LIBRARY_PATH I just get a blank line, so I assume its not even set so I don't know how this could be a problem

1

There are 1 answers

0
Zombo On

When saving output to a variable with Bash, I usually do this

read issue < <(~/bin/makeissue.sh)
echo "$issue"

If the output is multiple lines you can do this

read -d'' issue < <(~/bin/makeissue.sh)
echo "$issue"

or this

mapfile issue < <(~/bin/makeissue.sh)
echo "${issue[@]}"