Reputation: 1
I made a script to connect to my sql server. when I copy my script into my terminal it works fine.
I connect to my sql server with a raspberrypi using Tsql
but when I put my script into a file to run it automatic I get an error.
First my script:
tsql -H Server -U Username -P Password
Go
Use master
paste it into my shell
root@raspberrypi:~# tsql -H Server -U Username -P Password
Missing argument -p, looking for default instance ... found default instance, port 1433
locale is "nl_NL"
locale charset is "ISO-8859-1"
using default charset "ISO-8859-1"
1> GO
1> use master
2> go
1>
I put exactly the same script into the file data.sh But it won't work.
root@raspberrypi:~# ./data.sh
Missing argument -p, looking for default instance ... found default instance, port 1433
locale is "nl_NL"
locale charset is "ISO-8859-1"
using default charset "ISO-8859-1"
1>
Can anyone help me with this problem
thanks
Upvotes: 0
Views: 2260
Reputation: 1
You are probably using named pipes. Try adding -L [instance_name]
.
Upvotes: 0
Reputation: 8806
See this answer. For your data.sh script to work you need to pass the SQL statements into the tsql program. As you have it above, there is no input to the tsql program, so it just prints the prompt.
Try this in data.sh:
tsql -H Server -U Username -P Password <<EOF
GO
use master
GO
EOF
Upvotes: 2