What is wrong with this script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting What is wrong with this script?
# 1  
Old 07-19-2004
What is wrong with this script?

Hi,

Basically, i am reading a file and transferring files between two servers using sftp. I am checking the last character of the file which gives me the server number to transfer the file to..After i check the server number and try to include the sftp code....it gives me am error

syntax error: unexpected end of file....

This happens when ever i put sftp $host << EOF

Not sure where i am going wrong here....

I am attaching the script file

Can anyone help me with this

Thanks in adv
# 2  
Old 07-19-2004
The biggest thing I see wrong with it is you haven't picked one language to do it in. Seems to be a mixture of C++, sh, and/or others.

Care to enlighten me on what language it is?
Post your OS and version too.
As far as these lines go, they should work as long as /home/ravala/test already exist (tested by themselves in ksh on Solaris 2.6).

sftp x.xxx.xxx.xx << EOF
mkdir /home/ravala/test/test1
quit
EOF

Last edited by RTM; 07-19-2004 at 09:42 PM..
# 3  
Old 07-19-2004
hi,

i am doing this using bash script..

yes the sftp code works if run independently....

the problem is whenever it is included in the loop it gives me that error.
# 4  
Old 07-19-2004
So tell me, what is a comment in bash? I thought it was #.

You have the following...

// code for getting $strlen1

Isnt' that a comment in C++? I get an error if I add it to the script.

And you have
declare -a input
declare -a fileinput

(edited - as you can tell, I've never used bash - I thought the declare statements were also a C or C++ thing. My apologies).

How are you starting this (since you don't include the #!/path/bash in the start of the script)?

Try commenting out the sftp lines and put in a echo "I got to the sftp lines" - run your script - see if you still get the error because I don't know what you have in those other files that you are reading...so it makes it harder for me to quickly find what's wrong with the script. I've gotten into the second while but can't run your code.

Last edited by RTM; 07-19-2004 at 10:03 PM..
# 5  
Old 07-19-2004
Hey,

I am sorry.
// code is something i wanted to know that i have some code here... i did not want to dump the entire thing...

To be frank, i am new to scripting....

As , i told u...if i comment out the sftp code...everything works fine...but as soon as i add the sftp part it gives me the error...

i am assuming that there shud be something in the loops that is giving me the error...probably i am not looping properly....

i am basically looping thru the entries in 2 files

i declared the values to get the entries from a file into an array....

as i told if i include sftp ------ <<EOF, it gives me error
# 6  
Old 07-20-2004
Hey,

Got my script working....Was something to do with loops...

Created a fresh script and it worked fine...

Thanks for the help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Why result is wrong here ? whether break statement is wrong ?

Hi ! all I am just trying to check range in my datafile pls tell me why its resulting wrong admin@IEEE:~/Desktop$ cat test.txt 0 28.4 5 28.4 10 28.4 15 28.5 20 28.5 25 28.6 30 28.6 35 28.7 40 28.7 45 28.7 50 28.8 55 28.8 60 28.8 65 28.1... (2 Replies)
Discussion started by: Akshay Hegde
2 Replies

2. Shell Programming and Scripting

What is wrong with my script?

Dear All The following is part of my script: echo ${myarray} mytitle=`awk '{print substr(${myarray}, 0, length(${myarray})-4)}' /dev/null` the echo ${myarray} works fine; however, I keep getting following error for the mytitle=.. part: awk: line 1: syntax error at or near { awk: line... (3 Replies)
Discussion started by: littlewenwen
3 Replies

3. Shell Programming and Scripting

Can anyone tell me what's wrong with my script

Hi... I am fed up in file handing with array for comparing.... 1st I want save first 2 columns of file 1 I tried like this,, {getline< "file1";ln=$1; lt=$2}then I read second file's 1st and 2nd column..and saved like this and small calculation and initialization var1 =$1 var2 =$2... (5 Replies)
Discussion started by: Akshay Hegde
5 Replies

4. UNIX for Dummies Questions & Answers

What's wrong on this script?

I get this error on these lines when i run this script:"for i in /home;do file2=`ls -s $i` if ;then ls - s $i fi done (7 Replies)
Discussion started by: kotsos13
7 Replies

5. Shell Programming and Scripting

Script Gone Wrong

Hello all, so this is a script i did for an assignement, - first option greets the user according to the time after fetching his name - second options isn't implemented - third check the performance according to how many users are using the system - creates a log of names, time and ip of the... (14 Replies)
Discussion started by: ibzee33
14 Replies

6. Shell Programming and Scripting

what is wrong with this script?

Hi I've made a short script but it is not working. Can some pl. help me out in this? ./123.sh #! /usr/bin/ksh # for changing to this directory cd /layered/relational/scripts When I run the above scripts, it doesn't change to the above directory. I don't what is the problem? the... (2 Replies)
Discussion started by: Mike1234
2 Replies

7. UNIX for Dummies Questions & Answers

what is wrong with this script?

Hi, I have this example script which gives error ": unexpected operator/operand". I need the '' brackets for operator precedence. #!/bin/ksh x="abc" y="xyz" z="123" if -a then print "yes" else print "no" fi Thanks (2 Replies)
Discussion started by: rs1969
2 Replies

8. Shell Programming and Scripting

What's wrong with this script

I am trying to create a script but it is giving me errors on Cygwin for the following script. Could someone tell me, what am I doing wrong? choice=1000 echo "choice is $choice" while ; do echo "choice is $choice" echo 'Please select your option:' echo '1. Option 1' echo '2. Option 2'... (3 Replies)
Discussion started by: amitg1980
3 Replies

9. Shell Programming and Scripting

What is wrong with this script?

I keep getting errors messages for the "else" statement at line 81? #!/bin/ksh ######### Environment Setup ######### PATH=/gers/nurev/menu/pub/sbin:/gers/nurev/menu/pub/bin:/gers/nurev/menu/pub/mac :/gers/nurev/menu/adm/sbin:/gers/nurev/menu/adm/bin:/gers/nurev/menu/adm/mac:/ge... (8 Replies)
Discussion started by: heprox
8 Replies

10. UNIX for Dummies Questions & Answers

What is wrong with my script?

Hey guys, can someone help me with this script... #!/bin/sh dir=`pwd` for i in *.f do if then M=`wc -l < ${i} sed -e 's://.*::' < ${i} | \ (echo "//${i} -"$M ; cat - ) > $i.tmp chmod 700 $i ; mv ${i}.tmp $i ... (6 Replies)
Discussion started by: Lem2003
6 Replies
Login or Register to Ask a Question