You are not logged in.
#!/bin/bash
current_state=cat /home/phil/.screen_state
if ["$current_state" = "laptop"];
then
disper -S
echo TV > .screen_state
else
disper -s
echo laptop > .screen_state
fi
[phil@pwned ~]$ ./screenswitch.sh
./screenswitch.sh: line 3: /home/phil/.screen_state: Permission denied
./screenswitch.sh: line 5: [: missing `]'
[phil@pwned ~]$ cat /home/phil/.screen_state
laptop
[phil@pwned ~]$
I'm not sure why I'm getting the permission denied, and also I can't see whats wrong with line 5.
Last edited by Dethredic (2011-08-21 19:46:57)
Offline
IIRC you need spaces
if [ "foo" = "foo" ]; then
between '[' and another character.
Edit: Got it.
current_state=cat /home/phil/.screen_state
This is plain wrong. I get 'Permission denied' too.
Try
current_state=$(cat /home/phil/.screen_state)
Last edited by karol (2011-08-21 17:59:16)
Offline
Offline
Please remember to mark as solved :-)
Offline