Why My Script Stops After 1st Command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Why My Script Stops After 1st Command
# 1  
Old 05-25-2010
Why My Script Stops After 1st Command

My script is very simple. It call isql and then echo a message. The problem is after the 1st command (isql), it stops so that the echo line never gets executed. Can anyone let me know what is wrong?

Code:
#!/usr/bin/sh

userid=xxxx
server=xxxx
db=xxxx
pwd=xxxx

isql -U ${userid} -S ${server} -P ${pwd} -D ${db} << EOF -o result.log
set nocount on
go
select top 10 * from table
go
EOF

echo "finished"

the file "result.log" is created successfully but however the message "finished" never shows up.
# 2  
Old 05-25-2010
There might be an extra space after the last EOF.
# 3  
Old 05-26-2010
is ur isql command working properly ??

Code:
#!/usr/bin/sh

userid=xxxxxxx
server=xxxxxxxx
db=xxxxxxxx
pwd=xxxxxxx

isql -U ${userid} -S ${server} -P ${pwd} -D ${db} << EOF -o result.log
set nocount on
go
select something something
go
EOF

echo $"finished"[

make sure there is no space before 2nd EOF (Second EOF should be at the start of the line)
# 4  
Old 05-26-2010
Quote:
Originally Posted by robbyls
My script is very simple. It call isql and then echo a message. The problem is after the 1st command (isql), it stops so that the echo line never gets executed. Can anyone let me know what is wrong?

Code:
#!/usr/bin/sh

userid=xxxx
server=xxxx
db=xxxx
pwd=xxxx

isql -U ${userid} -S ${server} -P ${pwd} -D ${db} << EOF -o result.log
set nocount on
go
select top 10 * from table
go
EOF

echo "finished"

the file "result.log" is created successfully but however the message "finished" never shows up.
Yes, you are right! I removed the extra space character and now it works. thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy Script Stops

Good Morning, I have a copy script on Solaris 9 machine that is supposed to copy some files to a NAS using: cp -r /dir/dir/ /dir/dir/dirThe script doesn't finish. The directory contains user files of which one seems to copy fine, a second was failing until I did achmod -R -777 to it. Now,... (6 Replies)
Discussion started by: Stellaman1977
6 Replies

2. Shell Programming and Scripting

My script stops after logoff...why??

Hi' i am runing a script thats run with a loop...while loop true. when i exit the server..logon and again the script doenst run. its a bash script test.sh. i run it as: #./test.sh & what can be the priblem please? thanks alot (6 Replies)
Discussion started by: zigizag
6 Replies

3. Shell Programming and Scripting

My script stops working when using crontab

I have made a shell script(/bin/sh) that starts a perl script (that I haven't made my self) that's starts a ssh session. The ssh session uses a private/public key to login so no password is needed. The Perl script works perfect. But when I put it in a cronjob (crontab) the ssh connection asks... (6 Replies)
Discussion started by: splinter_cell
6 Replies

4. Shell Programming and Scripting

Script stops working after copying it

Hi all, When I cp a script, this section of the code stops reading from a file. if ; then while read dirtoclean do DIRSTOCLEAN=${DIRSTOCLEAN}' '$dirtoclean done < ${BASEDIR}test.conf fi ${DIRSTOCLEAN} doesn't return anything, even though it will work right before... (6 Replies)
Discussion started by: nicksantos1
6 Replies

5. Shell Programming and Scripting

while loop stops after first iteration - remote ssh exit command problem?

I have written the following script to update some Debian boxes. #!/bin/bash mxg_hosts_file="/etc/mxg/ssh-hosts" while read line ; do mxg_host="$(echo ${line} | awk -F":" '{print $1}')" mxg_port="$(echo ${line} | awk -F":" '{print $2}')" echo "Connecting and Upgrading... (3 Replies)
Discussion started by: jelloir
3 Replies

6. Shell Programming and Scripting

Script stops running after assigning empty string for a variable

Hi, This is the first time I see something like this, and I don't why it happens. Please give me some help. I am really appreciate it. Basically I am trying to remove all empty lines of an input.. #!/bin/bash set -e set -x str1=`echo -e "\nhaha" | grep -v ^$` #str2=`echo -e "\n" |... (4 Replies)
Discussion started by: yoyomano
4 Replies

7. Shell Programming and Scripting

Script with infinite loop stops after sometime

Hi I am working on a server that is set up and maintained by a third party. It seems whenever I run bash scripts in the background (with a &) with while loops in them they seem to me killed in around 2.5 hours. ( I am running them as a normal user with no special privileges ) . Is there a... (3 Replies)
Discussion started by: pkabali
3 Replies

8. Shell Programming and Scripting

cleartool - script stops after using setview

Hi Guys, See the below code. The command below the cleartool setview ITG_Automation is not executing. Could you please suggest. #!/bin/ksh echo $0 cleartool setview ITG_Automation echo $0 (3 Replies)
Discussion started by: ajincoep
3 Replies

9. Shell Programming and Scripting

Script stops running the remaining checks after becoming admin

Hi all, I encountered a problem where my script stops running the remaining checks after becoming an admin that is written within the script. For example: ========================================= #!/bin/sh check 1 # Runs successfully check 2 # Runs successfully /com/bin/admin #... (1 Reply)
Discussion started by: seanchew
1 Replies

10. OS X (Apple)

terminal script stops after script command :(.

Hello, i am trying to write a script for terminal for my mac that i may drag into the terminal and will excute the following command: script -akq Desktop/TerminalLogin/Cisco1Bob.txt telnet x.x.x.x the problem is that when i drag the text file to the terminal window the script stops after... (6 Replies)
Discussion started by: drdread
6 Replies
Login or Register to Ask a Question