I am passing a variable (with spaces inside of single quotes) as parameters to another csh script, but it is splitting them up in the second script. If I manually run the same line in tcsh, it works.
spacetest.csh:
#!/bin/csh -vx
set SERVER = "UAT"
set SUBJECT = "'Test Report $SERVER'"
set MESSAGE = "testmessage.msg"
set ATTACHMENTS = "'-a file1.csv -a file2.csv'"
emailtest.csh $SUBJECT $MESSAGE $ATTACHMENTS
emailtest.csh:
#!/bin/csh
echo "1 $1"
echo "2 $2"
echo "3 $3"
Since I am using -vx, it is showing what the parameters look like, but it is still splitting them up.
Output includes:
/scratch/hr-finance/scripts/emailtest.csh $SUBJECT $MESSAGE $ATTACHMENTS
/scratch/hr-finance/scripts/emailtest.csh 'Test Report UAT' testmessage.msg '-a file1.csv -a file2.csv'
1 'Test
2 Report
3 UAT'
Now if I copy-and-paste the line and run it in tcsh, it works as expected.
%emailtest.csh 'Test Report UAT' testmessage.msg '-a file1.csv -a file2.csv'
1 Test Report UAT
2 testmessage.msg
3 -a file1.csv -a file2.csv
%
If I try something with \" instead, I get an Unmatched double quote error:
%set SUBJECT = "\"Test Report $SERVER\""
Unmatched ".
Any ideas?