Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-26-2010, 08:42 PM   #1
Registered: Jun 2003
Location: Summit, NJ
Distribution: CentOS 5.4
Posts: 142

Rep: Reputation: 15
Post custom xen shutdown command fails

I have a custom command I've made to quickly shut down all of my xen instances.

[root@LCENT02 ~]# virtdown
-bash: syntax error near unexpected token `2'
As you can see it fails when I try to run it on the command line. It is stored in an ~/.env file in my home directory.

What is odd to me is if I open the .env file and copy the command from there and paste it into the command line, it does actually work!

[root@LCENT02 ~]# for i in `virsh list | grep -v -e Id -e --- -e Domain-0 | awk '{print $1}'`; do virsh shutdown $i; done
Domain 1 is being shutdown

Domain 2 is being shutdown

Domain 3 is being shutdown

And this is how I have the command entered into my .env file:

alias virtdown="for i in `virsh list | grep -v -e Id -e --- -e Domain-0 | awk '{print $1}'`; do virsh shutdown $i; done"
Why would this command work if you paste it onto the command line but not use the custom command virtdown?

Thanks in advance!!
Old 12-28-2010, 06:31 AM   #2
LQ Newbie
Registered: May 2010
Posts: 9

Rep: Reputation: 0
I am quite a Linux newbie but I have a few comments/suggestions.

You could of course just create a script file and put the command in it, that would almpost certainly solve your problem.

But if you are set on using a single alias file I would hazard a guess that the quotes ("") are causing your trouble. I do not use alias much but I wonder if it accepts ('') or possibly even (``) instead of the quotes.

Try this (the ('') already in the code has been changed to ("")):
alias virtdown='for i in `virsh list | grep -v -e Id -e --- -e Domain-0 | awk "{print $1}"`; do virsh shutdown $i; done'
It tries to run for me, but I do not have all the needed packages installed.

Last edited by wisnoskij; 12-28-2010 at 07:02 AM. Reason: formatting


bash, xen

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
'shutdown' command causing unclean shutdown silentwol Linux - Software 3 07-01-2009 02:01 AM
custom kernel xen-linux-system-2.6.26-1-xen-amd64 vasco2009 Linux - Software 0 03-30-2009 02:54 PM
Xen Fails to Boot worldgnat Linux - Kernel 2 07-14-2007 11:21 PM
'shutdown now' successful, 'shutdown -r now' fails Stomatella Linux - Hardware 4 05-23-2006 10:45 PM
LXer: Installing Xen 3.0 upon Debian Unstable, with a custom Kernel LXer Syndicated Linux News 0 01-03-2006 11:31 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:30 PM.

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