LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-23-2010, 10:55 AM   #1
tstrickland
Member
 
Registered: Jun 2005
Location: Lewisville, Texas
Posts: 36

Rep: Reputation: 15
Can't get script to run


I want to run a script at startup that will turn off my touchpad. I can do that by executing "synclient touchpadoff=1" in the Konsole terminal. However, I have to do it every time I log on. I want a script that will do this automatically when I start up.I was given the script

Quote:
#!/bin/bash
# toggle synaptic touchpad on/off

# get current state
SYNSTATE=$(synclient -l | grep TouchpadOff | awk '{ print $3 }')

# change to other state
if [ $SYNSTATE = 0 ]; then
* * synclient touchpadoff=1
elif [ $SYNSTATE = 1 ]; then
* * synclient touchpadoff=0
else
* * echo "Couldn't get touchpad status from synclient"
* * exit 1
fi
exit 0
I can't get it to run automatically in Kubuntu and I can't get it to run in the terminal. When I try with the terminal I get

Quote:
tom@DellNotebook:~$ ./togglepad.sh
./togglepad.sh: 15: *: not found
tom@DellNotebook:~$
I don't know what this is telling me. Anyway I tried to simplify the script as follows

Quote:
#!/bin/bash
# toggle synaptic touchpad on/off
* synclient touchpadoff = 1
exit 0
This didn't work either. The terminal output was

Quote:
tom@DellNotebook:~$ ./togglepad2.sh
./togglepad2.sh: line 3: *: command not found
tom@DellNotebook:~$
At this point, or perhaps earlier, I'm lost.

What to do. Thanks in advance for your help.
 
Old 05-23-2010, 11:00 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Quote:
Originally Posted by tstrickland View Post
I can't get it to run automatically in Kubuntu
Most Desktop Environments have a way to run applications at startup.


Quote:
Originally Posted by tstrickland View Post
I don't know what this is telling me.
Provide the full path.
 
Old 05-23-2010, 11:46 AM   #3
wmakowski
Member
 
Registered: Oct 2003
Location: Ohio
Distribution: Fedora 23, 24, RHL 5.2
Posts: 560

Rep: Reputation: 56
Let's start with the script and get it to work. There is a problem with the use of *'s. Those have special meaning in bash. By themselves they refer to the script name. When used as $* they give a complete list of arguments from the command line. In my opinion these should not be in the script at all.

If you were to put an * by itself, it would start a recursive routine. The script would continue to call itself unless there were conditional expressions to cause an exit somewhere along the line. In your case it tries to call itself, but can't find the togglepad.sh script because it is not in your $PATH. Try removing the *'s from your script.

We can figure out the best way to get it running automatically once the script is working.
 
Old 05-23-2010, 12:03 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Quote:
Originally Posted by wmakowski View Post
There is a problem with the use of *'s.
Uh. Good one. Completely read over that!
 
Old 05-23-2010, 12:10 PM   #5
fruttenboel
Member
 
Registered: Jul 2008
Location: Tilburg NL
Distribution: Slackware 14.2 ciurrent, kernel 3.18.11
Posts: 270

Rep: Reputation: 48
Quote:
Originally Posted by tstrickland View Post
I want to run a script at startup that will turn off my touchpad. I can do that by executing "synclient touchpadoff=1" in the Konsole terminal. However, I have to do it every time I log on.

I can't get it to run automatically in Kubuntu and I can't get it to run in the terminal. When I try with the terminal I get

What to do. Thanks in advance for your help.
You forgot to make it executable...

Code:
chmod 755 togglepad.sh
Or, if you like typing long command lines:

Code:
$ bash togglepad.sh
This ought to do the trick
 
Old 05-23-2010, 07:54 PM   #6
tstrickland
Member
 
Registered: Jun 2005
Location: Lewisville, Texas
Posts: 36

Original Poster
Rep: Reputation: 15
Can't get script to run

1. The path is /home/togglepad.sh

2. I don't know where the asterisks (**) came from. In my script those were spaces were the script is indented. I've attached a copy of the togglepad.sh file with .txt extension added so that it can be attached to this post.

3. The file is executable.

4. I ran "bash togglepad.sh" at the terminal prompt and got this:

tom@DellNotebook:~$ bash togglepad.sh
togglepad.sh: line 11: *: command not found
tom@DellNotebook:~$

I hope I've interpreted your recommendations correctly, but it still doesn't work.

Thanks.
Attached Files
File Type: txt togglepad.sh.txt (358 Bytes, 9 views)
 
Old 05-23-2010, 08:45 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
I see some funky characters where the "*"s used to be.
What editor are you using, did you type that script initially,
or copy & paste from some web page?

Do a diff of yours and what I attached.
Attached Files
File Type: txt togglepad.sh.txt (350 Bytes, 5 views)
 
Old 05-23-2010, 11:01 PM   #8
tstrickland
Member
 
Registered: Jun 2005
Location: Lewisville, Texas
Posts: 36

Original Poster
Rep: Reputation: 15
I retyped "togglepad2.sh" as follows"

Quote:
#!/bin/sh
# toggle synaptic touchpad on/off
synclient touchpadoff=1
and this works! I don't know why this works now and wouldn't work before I retyped it. Nevertheless, it works both when run from the Konsole terminal and when it is run automatically when I start up Kubuntu.

Thanks for all your help! If anyone has an idea of why this now works, I'd like to hear about it.
 
Old 05-23-2010, 11:24 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
As I said: "funky characters" in the script that bash couldn't make
any sense off.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
My BASH script work perfect when i run it manualy, but not when it run in the crontab roqarg Linux - Newbie 30 05-06-2010 02:37 PM
I want to run script on the server from client machine in windows in a perl script vpradeep Linux - Newbie 2 09-01-2008 04:29 AM
MySQL Updates With Null When Perl Script Run From Shell Script ThisGuyIKnow Programming 6 08-12-2008 10:56 AM
Is a script, run at boot time from init.d, run with root authority? tmbrwolf53 Linux - Server 2 03-31-2007 09:15 PM
on Network Up Script run? On Battery power run script? v2-ncl Linux - General 0 12-08-2003 10:34 AM


All times are GMT -5. The time now is 10:07 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration