Re: [ansible-project] Unable to execute shell script

2024-08-21 Thread Yogita Patil
Ah ok thanks for letting me know, will fix that. On Wed, Aug 21, 2024 at 5:13 PM Todd Lewis wrote: > The "stat" failed because you have a "." in front of > "/usr/src/power_consumption.sh". > > On 8/21/24 8:57 AM, Yogita Patil wrote: > > Ok thanks Todd. > > Also now I am getting a different error

Re: [ansible-project] Unable to execute shell script

2024-08-21 Thread Todd Lewis
The "stat" failed because you have a "." in front of "/usr/src/power_consumption.sh". On 8/21/24 8:57 AM, Yogita Patil wrote: Ok thanks Todd. Also now I am getting a different error, after I cleaned up the yml to keep only 1 task -  FAILED! => {     "ansible_facts": {         "discovered_in

Re: [ansible-project] Unable to execute shell script

2024-08-21 Thread Yogita Patil
This worked for me ...hooray!!! Many thanks everyone for all your inputs and support!!! - name: Shell script test hosts: all gather_facts: false tasks: - name: Start application shell: "/usr/src/power_consumption.sh" args: chdir: "/usr/src" executable: "/bin/bash" On

Re: [ansible-project] Unable to execute shell script

2024-08-21 Thread Yogita Patil
Ok thanks Todd. Also now I am getting a different error, after I cleaned up the yml to keep only 1 task - FAILED! => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" }, "changed": true, "cmd": [ "stat", "./usr/src/power_consumption.

Re: [ansible-project] Unable to execute shell script

2024-08-21 Thread Todd Lewis
Yogita, Do us a favor please and change this: ansible.builtin.command: ./power_consumption.sh to this: ansible.builtin.command: stat ./power_consumption.sh and let us see the results. Thanks. — Todd On 8/21/24 8:12 AM, Yogita Patil wrote: Yes yes I understand what you mean, and it does

Re: [ansible-project] Unable to execute shell script

2024-08-21 Thread Yogita Patil
I see, ok let me try that! , it runs via cli without it so that is why I hadn't added it. I will try that, thanks guys! On Wed, Aug 21, 2024 at 4:41 PM Dick Visser wrote: > On Wed, 21 Aug 2024 at 14:12, Yogita Patil > wrote: > > > > Yes yes I understand what you mean, and it does work if I add

Re: [ansible-project] Unable to execute shell script

2024-08-21 Thread Dick Visser
On Wed, 21 Aug 2024 at 14:12, Yogita Patil wrote: > > Yes yes I understand what you mean, and it does work if I add #!/bin/bash’ > at the beginning of my foo.sh Yes, but your power consumption script ALSO needs to have the correct shebang. -- You received this message because you are subscri

Re: [ansible-project] Unable to execute shell script

2024-08-21 Thread Yogita Patil
Yes yes I understand what you mean, and it does work if I add #!/bin/bash’ at the beginning of my foo.sh contents of foo.sh - #!/bin/bash echo "Hello world" However my power consumption script fails. Any idea what I am doing wrong there? Many thanks for your help! -Yogita. On Wed, Aug 21, 202

Re: [ansible-project] Unable to execute shell script

2024-08-21 Thread Stephen Maher
Hi, Your bash script must in include ‘#!/bin/bash’ to allow for its execution using bash hence the suggestion to add the executable verb to prove this was the case. Regards > On 21 Aug 2024, at 11:25, Yogita Patil wrote: > > The bash was just a trial, the is the script that I really care ab

Re: [ansible-project] Unable to execute shell script

2024-08-21 Thread Yogita Patil
The bash was just a trial, the is the script that I really care about running which runs perfectly from the command line - myScript.yml - name: Shell script test hosts: all tasks: - name: Run a shell command ansible.builtin.shell: power_consumption.sh register: foo_result

Re: [ansible-project] Unable to execute shell script

2024-08-21 Thread Stephen Maher
Hi, This if often because your ’shell’ script has the incorrect shebang at the top. If its a bash script then add executable: /bin/bash and try again, or check your script. Cheers. > On 21 Aug 2024, at 09:32, Yogita Patil wrote: > > Thanks for the responses guys, but these are the errors I

Re: [ansible-project] Unable to execute shell script

2024-08-18 Thread Dick Visser
Without any real data it's impossible to tell. Can you at a minimum post the error message? Sent from Gmail Mobile On Sun, Aug 18, 2024 at 13:14 Yogita Patil wrote: > Hi All, > > I am simply unable to execute a shell script on the remote host - this is > my code (all other tasks run correctly