# Unable to run a script via local-exec provisioner

**URL:** <https://discuss.hashicorp.com/t/unable-to-run-a-script-via-local-exec-provisioner/25694>\
**Category:** Terraform\
**Created:** [June 18, 2021, 11:46am UTC](https://discuss.hashicorp.com/t/unable-to-run-a-script-via-local-exec-provisioner/25694 "2021-06-18T11:46:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vamsi.gomatam](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/vamsi.gomatam/32/16315_2.png) [@vamsi.gomatam](https://discuss.hashicorp.com/u/vamsi.gomatam)\
**Post date:** [June 18, 2021, 11:46am UTC](https://discuss.hashicorp.com/t/unable-to-run-a-script-via-local-exec-provisioner/25694/1 "2021-06-18T11:46:33Z")

</div>

Hello Team,

I am trying to execute a script via local exec provisioner on destroying the instance using the below block inside the EC2 instance.  
resource “aws\_instance” “g2\_lb\_public” {  
\*\*\*\*\*_ **Instance definition** _  
provisioner “local-exec” {

```
interpreter = ["/bin/bash", "-c"]
when = destroy          
command = <<-EOT
"cd /home/script && bash run.sh"

```

EOT  
}  
I am getting the below error on running the terraform  
aws\_instance.g2\_lb\_public[0]: Destroying… [id=XXXX]  
aws\_instance.g2\_lb\_public[0]: Provisioning with ‘local-exec’…  
aws\_instance.g2\_lb\_public[0] (local-exec): Executing: ["/bin/bash" “-c” ““cd /home/script && bash run.sh”\n”]  
aws\_instance.g2\_lb\_public[0] (local-exec): /bin/bash: cd /home/script && bash run.sh: No such file or directory

Error: Error running command '“cd /home/script && bash run.sh”

': exit status 127. Output: /bin/bash: cd /home/script && bash run.sh: No such file or directory

Could you please help where I am doing it wrong? I need to run the script before destroying the instance.

Can someone please help me how to properly do this?

Regards,  
Vamsi
