LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   custom xen shutdown command fails (https://www.linuxquestions.org/questions/linux-newbie-8/custom-xen-shutdown-command-fails-852513/)

bluethundr 12-26-2010 08:42 PM

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

Code:

[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!

Code:

[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:

Code:

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!!

wisnoskij 12-28-2010 06:31 AM

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 ("")):
Code:

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.


All times are GMT -5. The time now is 02:58 PM.