If statement breaks when using except include


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting If statement breaks when using except include
# 1  
Old 05-15-2009
If statement breaks when using except include

I'm having an interesting problem, I'm pretty much a linux newbie, and my past 3 hours of google searching is not helping :P

So I'm trying to make an autologin script using expect, but whenever I use expect, it breaks everything not explicitly covered under expect.

Example, blahblahs added to keep discretion, only top part of if statement posted due to it breaking on the actual IF statement itself:

[code]
#!/usr/bin/expect

set site [lindex $argv 0]

if [ `cat key_hosts | grep $site` ]; then
spawn scp bin/quick_verify.sh root@(blahblah).$site.(blahblah).net:
expect "Password:"
send "(blahblah)\n"
spawn ssh root@(blahblah).$site.(blahblah).net
expect "Password:"
send "(blahblah)\n"
interact

When I run the program, I get the following results:

invalid command name "`cat"
while executing
"`cat key_hosts | grep $site` "
invoked from within
"if [ `cat key_hosts | grep $site` ]"
(file "/home/bmartin/bin/s.bak" line 6)

And yes I'm probably making a huge noob mistake, but there's nothing documenting what the noob mistake I'm making is! help! :P Also, when I try to echo the contents to a file instead, it says echo isn't a valid command, I'm so lost \_(O.o)_/

Thanks in advance.

Last edited by Franklin52; 05-15-2009 at 07:52 AM.. Reason: url removed
# 2  
Old 05-17-2009
Also as an aside, when I remove the expect, everything starts working agian, except the expect commands ofc.
# 3  
Old 05-20-2009
no ideas? Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Color coding breaks ls?

I found a script that almost takes care of a bit of clunkiness in git. I say almost, because when I use it, after it does what it's supposed to do, it breaks my shell, or something. After I use it, I can't use wildcards any more. I tried to run `jshint *.js` as I do a million times a day, but it... (3 Replies)
Discussion started by: GreatBigBore
3 Replies

2. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

3. UNIX for Dummies Questions & Answers

Page breaks and line breaks

Hi All, Need an urgent solution to an issue . We have created a ksh file or shell script which generates 1 DAT file. the DAT file contains extract of a select statement . Now the issue is , when we are executing the ksh file , the output is coimng with page breaks and line breaks . We have... (4 Replies)
Discussion started by: Ayaskant
4 Replies

4. UNIX for Dummies Questions & Answers

What breaks inittab

Today there was a situation where processes running from inittab was broken. Can someone help me understand, how to find out, who might have stopped those processes? Or how does it get broken? G (2 Replies)
Discussion started by: ggayathri
2 Replies

5. Shell Programming and Scripting

Help with wc and line breaks

Hi everyone, I have gone through the forum trying to find an answer to this question but was unsuccessful. I am hoping that someone can help me with this please. I am trying to get my script to recognise line breaks from a file and to give me a result for wc of each line. So basically, if you... (7 Replies)
Discussion started by: stargazerr
7 Replies

6. UNIX for Advanced & Expert Users

ping breaks

I have implemented advance routing fo load balancing and a script for and fail over on a Linux machine which run squid and dansguardian for proxying, i have three interfaces on this machine which are 10.201.108.254 eth1 external interface connected to service provider 10.201.109.254 eth2... (0 Replies)
Discussion started by: surfer24
0 Replies

7. Shell Programming and Scripting

any better way to remove line breaks

Hi, I got some log files which print the whole xml message in separate lines: e.g. 2008-10-01 14:21:44,561 INFO do something 2008-10-01 14:21:44,561 INFO print xml : <?xml version="1.0" encoding="UTF-8"?> <a> <b>my data</b> </a> 2008-10-01 14:21:44,563 INFO do something again I want... (3 Replies)
Discussion started by: csmklee
3 Replies

8. Shell Programming and Scripting

Fix the breaks

The file FTP'd got few breaks and the data looks like: ABCTOM NYMANAGER ABCDAVE NJ PROGRAMMER ABCJIM CTTECHLEAD ABCPETERCA HR and i want the output like: ABCTOM NYMANAGER ABCDAVE NJPROGRAMMER ABCJIM CTTECHLEAD ABCPETERCAHR can you please help me in writing the shell... (8 Replies)
Discussion started by: rlmadhav
8 Replies

9. Shell Programming and Scripting

Help on page breaks

Hi, I am new to Unix (AIX). I have a header (in a text file) that needs to be wrtitten on all the pages of a result file (text file). After the header is written, data needs to be read from a file A(text file) and inserted to the result file. If the number of lines reaches 80 in a page, page... (1 Reply)
Discussion started by: simhasuri
1 Replies

10. Programming

Page Breaks

Hi, I have a program in Pro*c when I run it I have no problem with the output but when it runs via the at command and except the output has page breaks every 66 lines. I don't want those page breaks to be in the output. any idea? (9 Replies)
Discussion started by: rama71
9 Replies
Login or Register to Ask a Question