这是我的脚本
#!/bin/bash
clear
PSQLSTART="INSERT INTO TABLE (Name, Description, Field3, Field4, Field5, Field6, Field7, Field8, Field9, Field10, Field11, Field12, Field13, Field14, Field15, Field16, Field17, Field18) VALUES"
echo "What is the name of my CSV File?"
read CSVFILE
echo "What is the server IP?"
read INTIP
echo "What is the server username?"
read INTUSER
echo "What is the server password?"
read INTPW
while IFS=\| read -r col1 col2 col3 col4 col5; do
sshpass -p "$INTPW" ssh -no StrictHostKeyChecking=no $INTUSER@$INTIP "echo $PSQLSTART$col1$col2$col3$col4$col5 >> /home/user/test.txt"
done < "$CSVFILE"
以下是我的 CSV 文件的样子
("testname|","|test description|", 1, 1, 1, 0, 0, "|test_url|", "", 0, 0, "", 0, 0, 0, 0, 0, 0);
这是我的输出和错误。
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF8)
bash: -c: line 0: syntax error near unexpected token `('
bash: -c: line 0: `echo INSERT INTO TABLE (Name, Description, Field3, Field4, Field5, Field6, Field7, Field8, Field9, Field10, Field11, Field12, Field13, Field14, Field15, Field16, Field17, Field18) VALUES("testname","test description", 1, 1, 1, 0, 0, "test_url|", "", 0, 0, "", 0, 0, 0, 0, 0, 0); >> /home/user/test.txt'
我查看了错误,但没发现我的脚本有什么问题。请帮忙。另外,我是 Bash 脚本的新手,所以这可能是一个简单的修复方法,我只是说不出来。