LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Works in alias, not in script (https://www.linuxquestions.org/questions/programming-9/works-in-alias-not-in-script-904772/)

lucmove 09-24-2011 08:48 AM

Works in alias, not in script
 
I have this alias in my tcsh:

Code:

alias hibernate 'xlock -mode blank &; sleep 2; echo -n mem >! /sys/power/state'
So when I run 'hibernate' the shell runs xlock to lock my desktop, waits 2 seconds then makes the computer hibernate. When the computer is woken up, it is properly locked. Fine.

Now I try to port it to a script:


Quote:

#!/bin/sh

xlock -mode blank &
sleep 2
echo -n mem >! /sys/power/state
It hibernates, but won't lock. If I remove the &, then it locks but won't hibernate immediately. It waits to be unlocked to hibernate.

What am I doing wrong?

grail 09-24-2011 09:45 AM

Well my first thought is that you are not using the same shell ... do you have a reason for this?


All times are GMT -5. The time now is 05:43 AM.