LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-03-2007, 07:42 AM   #1
tine
LQ Newbie
 
Registered: Sep 2004
Posts: 10

Rep: Reputation: 0
bash scripting help needed


If i enter this line directly to terminal it works and does what it's supposed to:
Code:
echo 'P=`ps auxc | grep btsco`; if [ "x$P" == "x" ]; then `btsco -r -f 00:1A:45:07:B7:A4`& fi' |bash -f -s
My goal is to create script with endless loop, entering that command above every 45second, but i'm unable to do so. Here is what i have tried, but it gives me errors:
Code:
#!/bin/sh
while true
do
	 P=`ps auxc | grep btsco`
	 if [ "x$P" == "x" ]
	 then 'btsco -r -f '00:1A:45:07:B7:A4'& fi' |bash -f -s
sleep 45
done
It gives me:
./btsco2.sh: line 8: syntax error near unexpected token `done'
./btsco2.sh: line 8: `done'

Please help me

-Tine
 
Old 09-03-2007, 08:02 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Code:
then 'btsco -r -f '00:1A:45:07:B7:A4'& fi' |bash -f -s
It is a problem with the line above: you should remove the quotes and indent the if-then structure. On the command line you used the reversed quotes, here you're using the single quotes.
 
Old 09-03-2007, 08:20 AM   #3
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Also you need a 'fi' statement to end the if statement.
 
Old 09-03-2007, 09:13 AM   #4
tine
LQ Newbie
 
Registered: Sep 2004
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks colucix, i got it working!
-Tine
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
a little scripting help needed!! vatsan1 Linux - General 6 09-02-2007 08:50 AM
Bash scripting help needed Zylar Linux - Newbie 8 05-03-2007 08:32 AM
Bash Scripting newb.. Advice needed. trey85stang Linux - General 5 09-28-2006 12:05 PM
bash scripting --- some help needed rajsharma Linux - Software 1 09-09-2005 02:49 AM
Scripting help needed. stonelee Linux - Software 2 09-29-2003 09:47 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration