Bacula-users

Re: [Bacula-users] Running complex commands or scripts remotely on a client

2012-09-06 02:39:27
Subject: Re: [Bacula-users] Running complex commands or scripts remotely on a client
From: Christian Manal <moenoel AT informatik.uni-bremen DOT de>
To: bacula-users AT lists.sourceforge DOT net
Date: Thu, 06 Sep 2012 08:36:50 +0200
On 06.09.2012 08:17, Alex Lucas wrote:
> On 06/09/12 12:10, ganiuszka wrote:
>> W dniu 06.09.2012 03:23, Alex Lucas pisze:
>>> On 05/09/12 19:24, Christian Manal wrote:
>>>> On 05.09.2012 12:43, Alex Lucas wrote:
>>>>> Dears,
>>>>>
>>>>> Is there a way to run a complex command or even a script on a client?
>>>>>
>>>>> So far I have tried two ways and failed:
>>>>> 1) when a command (e.g. in "ClientRunBeforeJob") has something like
>>>>> "echo test > /tmp/test.out" bacula runs it on the client as "echo" as
>>>>> command and the rest as the argument. i.e. there is no
>>>>> /tmp/test.out on
>>>>> the client
>>>>> 2) when I run "test.sh" which is in the PATH on the bacula director it
>>>>> fails, I guess because there is no identical script on the client.
>>>>>
>>>>> Any suggestions?
>>>> Hi,
>>>>
>>>> all the Run-statements execute what is defined directly, without a
>>>> shell. So output redirection and stuff won't work unless you do
>>>> something like this:
>>>>
>>>>     ClientRunBeforeJob = "/bin/bash -c 'echo foo >/tmp/foo.out'"
>>> Thank you, this does it. One related question: is because I have a few
>>> commands to run, is there a way to make the commands split across
>>> several lines (for readability) ?
>>>
>>> e.g.
>>>
>>> ClientRunBeforeJob = "/bin/bash -c 'command one
>>>                        command two'"
>>>
>>> doesn't seem to work.
>>
>> Hi,
>>
>> It works for me. Did you try to use semicolon character for separate
>> elementary commands?
>>
>> Example:
>>
>> ClientRunBeforeJob = "/bin/bash -c 'echo aaa >/tmp/foo1.out; echo bbb
>>> /tmp/foo2.out'"
> Hi gani,
> It works with ";" like you mentioned above but I was asking about
> splitting the command across multiple lines in the configuration file --
> when there are many commands it would make it easier to read.

Have you tried escaping the linebreaks with a backslash? Though, if you
have multiple commands to run, I'd rather go with a separate script,
instead of putting them into the config file.


Regards,
Christian Manal

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users