LinuxQuestions.org
Review your favorite Linux distribution.
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-24-2011, 08:48 AM   #1
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Rep: Reputation: 110Reputation: 110
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?
 
Old 09-24-2011, 09:45 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,999

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


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
Shell script: can you tell if a script is called via an alias? BrianK Programming 11 10-01-2009 11:16 AM
An alias works for http and https (i donīt want it) albinworld Linux - Server 1 01-20-2009 02:41 PM
Calling alias command in script snowman81 Linux - Newbie 4 04-06-2008 02:39 PM
alias within a script lordofring Linux - Software 4 03-06-2006 02:49 PM
alias does not work in shell script mannahazarika Programming 9 01-20-2006 01:56 PM

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

All times are GMT -5. The time now is 03:25 PM.

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