# Recipe executing shell command

**URL:** <https://discourse.chef.io/t/recipe-executing-shell-command/2329>\
**Category:** Chef Infra (archive)\
**Created:** [January 10, 2012, 7:13pm UTC](https://discourse.chef.io/t/recipe-executing-shell-command/2329 "2012-01-10T19:13:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kelly\_Goedert](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kelly_goedert/32/769_2.png) [@Kelly\_Goedert](https://discourse.chef.io/u/Kelly_Goedert)\
**Post date:** [January 10, 2012, 7:13pm UTC](https://discourse.chef.io/t/recipe-executing-shell-command/2329/1 "2012-01-10T19:13:14Z")

</div>

Hi,

I am trying to create a recipe that will make a silent install of a  
jdk1.5. The recipe is like this:

remote\_file “#{user\_home}/install/jdk-1\_5\_0\_22-linux-amd64.bin” do  
source "[http://10.1.1.6/files/jdk-1\_5\_0\_22-linux-amd64.bin](http://10.1.1.6/files/jdk-1_5_0_22-linux-amd64.bin)"  
owner user\_name  
group user\_name  
mode "0777"  
end

remote\_file “#{user\_home}/install/answerjdk5” do  
source "[http://10.1.1.6/files/answerjdk5](http://10.1.1.6/files/answerjdk5)"  
owner user\_name  
group user\_name  
mode "0755"  
end

execute “install\_jdk5” do  
command "#{user\_home}/install/jdk-1\_5\_0\_22-linux-amd64.bin \<  
#{user\_home}/install/answerjdk5 \> /dev/null"  
action :run  
end

The files are downloaded correctly and if I execute the command  
manually it works fine. In the client log, everything seems to be ok.  
But the jdk folder is not created.

INFO: Processing  
remote\_file[/home/mee/install/jdk-1\_5\_0\_22-linux-amd64.bin] action  
create (dev-env::default line 60)  
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing  
remote\_file[/home/mee/install/answerjdk5] action create  
(dev-env::default line 67)  
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing  
execute[install\_jdk5] action run (dev-env::default line 74)  
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: execute[install\_jdk5]  
sh(/home/mee/install/jdk-1\_5\_0\_22-linux-amd64.bin \<  
/home/mee/install/answerjdk5 \> /dev/null)  
[Tue, 10 Jan 2012 17:11:40 -0200] INFO: execute[install\_jdk5] ran successfully  
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Chef Run complete in 6.528239 seconds  
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Running report handlers  
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Report handlers complete

Can somebody help?

Thanks

Kelly

---

<div class="post-metadata">

**Author:** ![Matt\_Ray\_OPSCODE](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/matt_ray_opscode/32/459_2.png) [@Matt\_Ray\_OPSCODE](https://discourse.chef.io/u/Matt_Ray_OPSCODE)\
**Post date:** [January 10, 2012, 7:14pm UTC](https://discourse.chef.io/t/recipe-executing-shell-command/2329/2 "2012-01-10T19:14:56Z")

</div>

You may need to use the 'cwd' parameter for the execute.

Thanks,  
Matt Ray  
Senior Technical Evangelist | Opscode Inc.  
[matt@opscode.com](mailto:matt@opscode.com) | (512) 731-2218  
Twitter, IRC, GitHub: mattray

On Tue, Jan 10, 2012 at 1:13 PM, Kelly Goedert [kelly.goedert@gmail.com](mailto:kelly.goedert@gmail.com) wrote:

> Hi,
> 
> I am trying to create a recipe that will make a silent install of a  
> jdk1.5. The recipe is like this:
> 
> remote\_file "#{user\_home}/install/jdk-1\_5\_0\_22-linux-amd64.bin" do  
> source "[http://10.1.1.6/files/jdk-1\_5\_0\_22-linux-amd64.bin](http://10.1.1.6/files/jdk-1_5_0_22-linux-amd64.bin)"  
> owner user\_name  
> group user\_name  
> mode "0777"  
> end
> 
> remote\_file "#{user\_home}/install/answerjdk5" do  
> source "[http://10.1.1.6/files/answerjdk5](http://10.1.1.6/files/answerjdk5)"  
> owner user\_name  
> group user\_name  
> mode "0755"  
> end
> 
> execute "install\_jdk5" do  
> command "#{user\_home}/install/jdk-1\_5\_0\_22-linux-amd64.bin \<  
> #{user\_home}/install/answerjdk5 \> /dev/null"  
> action :run  
> end
> 
> The files are downloaded correctly and if I execute the command  
> manually it works fine. In the client log, everything seems to be ok.  
> But the jdk folder is not created.
> 
> INFO: Processing  
> remote\_file[/home/mee/install/jdk-1\_5\_0\_22-linux-amd64.bin] action  
> create (dev-env::default line 60)  
> [Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing  
> remote\_file[/home/mee/install/answerjdk5] action create  
> (dev-env::default line 67)  
> [Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing  
> execute[install\_jdk5] action run (dev-env::default line 74)  
> [Tue, 10 Jan 2012 17:11:38 -0200] INFO: execute[install\_jdk5]  
> sh(/home/mee/install/jdk-1\_5\_0\_22-linux-amd64.bin \<  
> /home/mee/install/answerjdk5 \> /dev/null)  
> [Tue, 10 Jan 2012 17:11:40 -0200] INFO: execute[install\_jdk5] ran successfully  
> [Tue, 10 Jan 2012 17:11:41 -0200] INFO: Chef Run complete in 6.528239 seconds  
> [Tue, 10 Jan 2012 17:11:41 -0200] INFO: Running report handlers  
> [Tue, 10 Jan 2012 17:11:41 -0200] INFO: Report handlers complete
> 
> Can somebody help?
> 
> Thanks
> 
> Kelly

---

<div class="post-metadata">

**Author:** ![Bryan\_Berry](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/bryan_berry/32/213_2.png) [@Bryan\_Berry](https://discourse.chef.io/u/Bryan_Berry)\
**Post date:** [January 10, 2012, 7:26pm UTC](https://discourse.chef.io/t/recipe-executing-shell-command/2329/3 "2012-01-10T19:26:18Z")

</div>

i would try "bash -x ./....bin ..." to see exactly what the shell is executing

On Tue, Jan 10, 2012 at 8:14 PM, Matt Ray [matt@opscode.com](mailto:matt@opscode.com) wrote:

> You may need to use the 'cwd' parameter for the execute.
> 
> Thanks,  
> Matt Ray  
> Senior Technical Evangelist | Opscode Inc.  
> [matt@opscode.com](mailto:matt@opscode.com) | (512) 731-2218  
> Twitter, IRC, GitHub: mattray
> 
> On Tue, Jan 10, 2012 at 1:13 PM, Kelly Goedert [kelly.goedert@gmail.com](mailto:kelly.goedert@gmail.com) wrote:
> 
> > Hi,
> > 
> > I am trying to create a recipe that will make a silent install of a  
> > jdk1.5. The recipe is like this:
> > 
> > remote\_file "#{user\_home}/install/jdk-1\_5\_0\_22-linux-amd64.bin" do  
> > source "[http://10.1.1.6/files/jdk-1\_5\_0\_22-linux-amd64.bin](http://10.1.1.6/files/jdk-1_5_0_22-linux-amd64.bin)"  
> > owner user\_name  
> > group user\_name  
> > mode "0777"  
> > end
> > 
> > remote\_file "#{user\_home}/install/answerjdk5" do  
> > source "[http://10.1.1.6/files/answerjdk5](http://10.1.1.6/files/answerjdk5)"  
> > owner user\_name  
> > group user\_name  
> > mode "0755"  
> > end
> > 
> > execute "install\_jdk5" do  
> > command "#{user\_home}/install/jdk-1\_5\_0\_22-linux-amd64.bin \<  
> > #{user\_home}/install/answerjdk5 \> /dev/null"  
> > action :run  
> > end
> > 
> > The files are downloaded correctly and if I execute the command  
> > manually it works fine. In the client log, everything seems to be ok.  
> > But the jdk folder is not created.
> > 
> > INFO: Processing  
> > remote\_file[/home/mee/install/jdk-1\_5\_0\_22-linux-amd64.bin] action  
> > create (dev-env::default line 60)  
> > [Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing  
> > remote\_file[/home/mee/install/answerjdk5] action create  
> > (dev-env::default line 67)  
> > [Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing  
> > execute[install\_jdk5] action run (dev-env::default line 74)  
> > [Tue, 10 Jan 2012 17:11:38 -0200] INFO: execute[install\_jdk5]  
> > sh(/home/mee/install/jdk-1\_5\_0\_22-linux-amd64.bin \<  
> > /home/mee/install/answerjdk5 \> /dev/null)  
> > [Tue, 10 Jan 2012 17:11:40 -0200] INFO: execute[install\_jdk5] ran successfully  
> > [Tue, 10 Jan 2012 17:11:41 -0200] INFO: Chef Run complete in 6.528239 seconds  
> > [Tue, 10 Jan 2012 17:11:41 -0200] INFO: Running report handlers  
> > [Tue, 10 Jan 2012 17:11:41 -0200] INFO: Report handlers complete
> > 
> > Can somebody help?
> > 
> > Thanks
> > 
> > Kelly

---

<div class="post-metadata">

**Author:** ![Matt\_Ray\_OPSCODE](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/matt_ray_opscode/32/459_2.png) [@Matt\_Ray\_OPSCODE](https://discourse.chef.io/u/Matt_Ray_OPSCODE)\
**Post date:** [January 10, 2012, 8:52pm UTC](https://discourse.chef.io/t/recipe-executing-shell-command/2329/4 "2012-01-10T20:52:19Z")

</div>

Running the chef-client with "-l debug" will also show you more output.

Thanks,  
Matt Ray  
Senior Technical Evangelist | Opscode Inc.  
[matt@opscode.com](mailto:matt@opscode.com) | (512) 731-2218  
Twitter, IRC, GitHub: mattray

On Tue, Jan 10, 2012 at 1:26 PM, Bryan Berry [bryan.berry@gmail.com](mailto:bryan.berry@gmail.com) wrote:

> i would try "bash -x ./....bin ..." to see exactly what the shell is executing
> 
> On Tue, Jan 10, 2012 at 8:14 PM, Matt Ray [matt@opscode.com](mailto:matt@opscode.com) wrote:
> 
> > You may need to use the 'cwd' parameter for the execute.
> > 
> > Thanks,  
> > Matt Ray  
> > Senior Technical Evangelist | Opscode Inc.  
> > [matt@opscode.com](mailto:matt@opscode.com) | (512) 731-2218  
> > Twitter, IRC, GitHub: mattray
> > 
> > On Tue, Jan 10, 2012 at 1:13 PM, Kelly Goedert [kelly.goedert@gmail.com](mailto:kelly.goedert@gmail.com) wrote:
> > 
> > > Hi,
> > > 
> > > I am trying to create a recipe that will make a silent install of a  
> > > jdk1.5. The recipe is like this:
> > > 
> > > remote\_file "#{user\_home}/install/jdk-1\_5\_0\_22-linux-amd64.bin" do  
> > > source "[http://10.1.1.6/files/jdk-1\_5\_0\_22-linux-amd64.bin](http://10.1.1.6/files/jdk-1_5_0_22-linux-amd64.bin)"  
> > > owner user\_name  
> > > group user\_name  
> > > mode "0777"  
> > > end
> > > 
> > > remote\_file "#{user\_home}/install/answerjdk5" do  
> > > source "[http://10.1.1.6/files/answerjdk5](http://10.1.1.6/files/answerjdk5)"  
> > > owner user\_name  
> > > group user\_name  
> > > mode "0755"  
> > > end
> > > 
> > > execute "install\_jdk5" do  
> > > command "#{user\_home}/install/jdk-1\_5\_0\_22-linux-amd64.bin \<  
> > > #{user\_home}/install/answerjdk5 \> /dev/null"  
> > > action :run  
> > > end
> > > 
> > > The files are downloaded correctly and if I execute the command  
> > > manually it works fine. In the client log, everything seems to be ok.  
> > > But the jdk folder is not created.
> > > 
> > > INFO: Processing  
> > > remote\_file[/home/mee/install/jdk-1\_5\_0\_22-linux-amd64.bin] action  
> > > create (dev-env::default line 60)  
> > > [Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing  
> > > remote\_file[/home/mee/install/answerjdk5] action create  
> > > (dev-env::default line 67)  
> > > [Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing  
> > > execute[install\_jdk5] action run (dev-env::default line 74)  
> > > [Tue, 10 Jan 2012 17:11:38 -0200] INFO: execute[install\_jdk5]  
> > > sh(/home/mee/install/jdk-1\_5\_0\_22-linux-amd64.bin \<  
> > > /home/mee/install/answerjdk5 \> /dev/null)  
> > > [Tue, 10 Jan 2012 17:11:40 -0200] INFO: execute[install\_jdk5] ran successfully  
> > > [Tue, 10 Jan 2012 17:11:41 -0200] INFO: Chef Run complete in 6.528239 seconds  
> > > [Tue, 10 Jan 2012 17:11:41 -0200] INFO: Running report handlers  
> > > [Tue, 10 Jan 2012 17:11:41 -0200] INFO: Report handlers complete
> > > 
> > > Can somebody help?
> > > 
> > > Thanks
> > > 
> > > Kelly

---

<div class="post-metadata">

**Author:** ![Kelly\_Goedert](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kelly_goedert/32/769_2.png) [@Kelly\_Goedert](https://discourse.chef.io/u/Kelly_Goedert)\
**Post date:** [January 11, 2012, 9:34am UTC](https://discourse.chef.io/t/recipe-executing-shell-command/2329/5 "2012-01-11T09:34:57Z")

</div>

Adding the cwd parameter solved the problem

Thanks

On Tue, Jan 10, 2012 at 5:14 PM, Matt Ray [matt@opscode.com](mailto:matt@opscode.com) wrote:

> You may need to use the 'cwd' parameter for the execute.
> 
> Thanks,  
> Matt Ray  
> Senior Technical Evangelist | Opscode Inc.  
> [matt@opscode.com](mailto:matt@opscode.com) | (512) 731-2218  
> Twitter, IRC, GitHub: mattray
> 
> On Tue, Jan 10, 2012 at 1:13 PM, Kelly Goedert [kelly.goedert@gmail.com](mailto:kelly.goedert@gmail.com) wrote:
> 
> > Hi,
> > 
> > I am trying to create a recipe that will make a silent install of a  
> > jdk1.5. The recipe is like this:
> > 
> > remote\_file "#{user\_home}/install/jdk-1\_5\_0\_22-linux-amd64.bin" do  
> > source "[http://10.1.1.6/files/jdk-1\_5\_0\_22-linux-amd64.bin](http://10.1.1.6/files/jdk-1_5_0_22-linux-amd64.bin)"  
> > owner user\_name  
> > group user\_name  
> > mode "0777"  
> > end
> > 
> > remote\_file "#{user\_home}/install/answerjdk5" do  
> > source "[http://10.1.1.6/files/answerjdk5](http://10.1.1.6/files/answerjdk5)"  
> > owner user\_name  
> > group user\_name  
> > mode "0755"  
> > end
> > 
> > execute "install\_jdk5" do  
> > command "#{user\_home}/install/jdk-1\_5\_0\_22-linux-amd64.bin \<  
> > #{user\_home}/install/answerjdk5 \> /dev/null"  
> > action :run  
> > end
> > 
> > The files are downloaded correctly and if I execute the command  
> > manually it works fine. In the client log, everything seems to be ok.  
> > But the jdk folder is not created.
> > 
> > INFO: Processing  
> > remote\_file[/home/mee/install/jdk-1\_5\_0\_22-linux-amd64.bin] action  
> > create (dev-env::default line 60)  
> > [Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing  
> > remote\_file[/home/mee/install/answerjdk5] action create  
> > (dev-env::default line 67)  
> > [Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing  
> > execute[install\_jdk5] action run (dev-env::default line 74)  
> > [Tue, 10 Jan 2012 17:11:38 -0200] INFO: execute[install\_jdk5]  
> > sh(/home/mee/install/jdk-1\_5\_0\_22-linux-amd64.bin \<  
> > /home/mee/install/answerjdk5 \> /dev/null)  
> > [Tue, 10 Jan 2012 17:11:40 -0200] INFO: execute[install\_jdk5] ran successfully  
> > [Tue, 10 Jan 2012 17:11:41 -0200] INFO: Chef Run complete in 6.528239 seconds  
> > [Tue, 10 Jan 2012 17:11:41 -0200] INFO: Running report handlers  
> > [Tue, 10 Jan 2012 17:11:41 -0200] INFO: Report handlers complete
> > 
> > Can somebody help?
> > 
> > Thanks
> > 
> > Kelly
