# Invoking shell scripts from Legato app

**URL:** <https://forum.legato.io/t/invoking-shell-scripts-from-legato-app/5575>\
**Category:** Legato Application Framework\
**Created:** [January 16, 2021, 9:25pm UTC](https://forum.legato.io/t/invoking-shell-scripts-from-legato-app/5575 "2021-01-16T21:25:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dave-k](https://avatars.discourse-cdn.com/v4/letter/d/9fc29f/32.png) [@dave-k](https://forum.legato.io/u/dave-k)\
**Post date:** [January 16, 2021, 9:25pm UTC](https://forum.legato.io/t/invoking-shell-scripts-from-legato-app/5575/1 "2021-01-16T21:25:26Z")

</div>

We’re trying to invoke some simple shell scripts from an unsandboxed Legato app that uses the WP 7603 but have so far been unable to do so. The scripts are present on the module (installed manually at this point) and we can run them all manually so I don’t think there are any path or permissions issues. It seems as though something is needed by Legato, I presume in the .adef, but don’t know what that is.

This seems like such a simple requirement I can’t believe it’s going to require customizing linux as installed on the module with Yocto or anything of that complexity, and assume it’s just something we’ve overlooked? We’re invoking the scripts using calls with this format: _system(“/bin/sh /home/scripts/test\_script”);_

Any help would be appreciated as we’re stymied at this point.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [January 16, 2021, 9:48pm UTC](https://forum.legato.io/t/invoking-shell-scripts-from-legato-app/5575/2 "2021-01-16T21:48:21Z")

</div>

I remember there should not be problem, you can see here : (maybe without the /bin/sh??? )

> [@Core dump when running script to get a file](https://forum.legato.io/t/core-dump-when-running-script-to-get-a-file/3158/16):
>
> No, because this is a public forum and for security measures it has keys in the script. But you can do it by creating an AWS S3 resource and putting a 6 Meg file there. Here is the template script: #!/bin/sh outputFile=“Your\_PATH” amzFile=“AMAZON\_FILE\_PATH” bucket=“YOUR\_BUCKET” resource=“/${bucket}/${amzFile}” contentType=“application/x-compressed-tar” dateValue=date -R stringToSign=“GET\n\n${contentType}\n${dateValue}\n${resource}” s3Key=“YOUR\_S3\_KEY” s3Secret=“YOUR\_S3SECRET” signa…

---

<div class="post-metadata">

**Author:** ![dave-k](https://avatars.discourse-cdn.com/v4/letter/d/9fc29f/32.png) [@dave-k](https://forum.legato.io/u/dave-k)\
**Post date:** [January 18, 2021, 10:35pm UTC](https://forum.legato.io/t/invoking-shell-scripts-from-legato-app/5575/3 "2021-01-18T22:35:23Z")

</div>

Thanks for the response. Unfortunately removing /bin/sh made no difference (I think I tried with and without it - should have mentioned that). Looking at the return from the system call it’s 32512, which seems like it might be a path issue, but I’m using the full path. I even tried changing to the script dir first but that didn’t work. Something to do with busybox maybe?

Following your link it looks like some of the previous user’s issues were resolved by upgrading from 17.11 but we’re already using a newer legato than that (18.10.3).

So your _system(“/tmp/test.sh”)_ call runs just like that? Nothing had to be added to the .adef?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [January 19, 2021, 2:43am UTC](https://forum.legato.io/t/invoking-shell-scripts-from-legato-app/5575/4 "2021-01-19T02:43:45Z")

</div>

I don’t see problem on WP76 FW R13.  
You can use my hello6.tar.gz.  
[hello6.tar.gz](https://forum.legato.io/uploads/short-url/czj2K4NaAp4M02tLAjqZGY8p95w.gz) (314.7 KB)

root@swi-mdm9x28-wp:~# chmod 777 /tmp/test.sh  
root@swi-mdm9x28-wp:~# /tmp/test.sh  
root@swi-mdm9x28-wp:~# ls /tmp/123.txt  
/tmp/123.txt  
root@swi-mdm9x28-wp:~# cat /tmp/123.txt  
123  
root@swi-mdm9x28-wp:~# rm /tmp/123.txt  
root@swi-mdm9x28-wp:~# ls /tmp/  
hello6.wp76xx.update legato test.sh  
hosts pkgdwl thermal\_engi\_ipc  
ld.so.cache psm\_socket tmpfdbtable.txt  
ld.so.conf sock0  
root@swi-mdm9x28-wp:~# update /tmp/hello6.wp76xx.update  
Unpacking package: 100% ++++++++++++++++++++++++++++++++++++++++++++++++++  
Applying update: 100% ++++++++++++++++++++++++++++++++++++++++++++++++++  
SUCCESS  
root@swi-mdm9x28-wp:~# app status  
[running] atAirVantage  
[running] atQmiLinker  
[running] atService  
[running] audioService  
[running] avcService  
[running] cellNetService  
[running] dataConnectionService  
[running] fwupdateService  
[running] gpioService  
[running] modemService  
[running] portService  
[running] positioningService  
[running] powerMgr  
[running] qmiAirVantage  
[running] secStore  
[stopped] smsInboxService  
[stopped] spiService  
[stopped] tools  
[stopped] voiceCallService  
[stopped] wifi  
[stopped] wifiApTest  
[stopped] wifiClientTest  
[running] wifiService  
[stopped] wifiWebAp  
[stopped] hello6  
root@swi-mdm9x28-wp:~# ls /tmp/  
hello6.wp76xx.update legato test.sh  
hosts pkgdwl thermal\_engi\_ipc  
ld.so.cache psm\_socket tmpfdbtable.txt  
ld.so.conf sock0  
root@swi-mdm9x28-wp:~# app start hello6  
root@swi-mdm9x28-wp:~# ls /tmp/  
123.txt ld.so.conf sock0  
hello6.wp76xx.update legato test.sh  
hosts pkgdwl thermal\_engi\_ipc  
ld.so.cache psm\_socket tmpfdbtable.txt  
root@swi-mdm9x28-wp:~#

---

<div class="post-metadata">

**Author:** ![dave-k](https://avatars.discourse-cdn.com/v4/letter/d/9fc29f/32.png) [@dave-k](https://forum.legato.io/u/dave-k)\
**Post date:** [January 27, 2021, 9:31pm UTC](https://forum.legato.io/t/invoking-shell-scripts-from-legato-app/5575/5 "2021-01-27T21:31:23Z")

</div>

Thanks jyijyi, confirmed it works with FW R13. Unfortunately that version is not supported by Dev. Studio so we may have to use it unsupported, or move to VS Code (had been hoping to defer that for a while…)

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [January 28, 2021, 12:56am UTC](https://forum.legato.io/t/invoking-shell-scripts-from-legato-app/5575/6 "2021-01-28T00:56:54Z")

</div>

Are you using wp76 module?  
I remember there is fw r13 in developer studio for wp76 module.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/legato1/original/2X/1/1d7794d28cce74d2ac4d9651ed814ecefad65b80.png)

---

<div class="post-metadata">

**Author:** ![dave-k](https://avatars.discourse-cdn.com/v4/letter/d/9fc29f/32.png) [@dave-k](https://forum.legato.io/u/dave-k)\
**Post date:** [January 28, 2021, 7:40pm UTC](https://forum.legato.io/t/invoking-shell-scripts-from-legato-app/5575/7 "2021-01-28T19:40:01Z")

</div>

That version shows up as one of the available packages and is what we’ve installed, however according to the notifications tab it’s not supported. At the moment we’re using it anyway as it does seem to work.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/legato1/original/2X/d/d28bf24e1b02455c571e0f0be0f6710394f16c0e.png)

---

<div class="post-metadata">

**Author:** ![akshaysk](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/akshaysk/32/1212_2.png) [@akshaysk](https://forum.legato.io/u/akshaysk)\
**Post date:** [January 29, 2021, 4:45am UTC](https://forum.legato.io/t/invoking-shell-scripts-from-legato-app/5575/8 "2021-01-29T04:45:26Z")

</div>

@dave-k ,  
Please post the response for cat /etc/legato/version . I am suspecting that you are running R13.1 not R13 which could be the reason why you are getting this warning about the version .

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [January 29, 2021, 4:53am UTC](https://forum.legato.io/t/invoking-shell-scripts-from-legato-app/5575/9 "2021-01-29T04:53:00Z")

</div>

this warning actually does not have problem, I usually see this but I can still download application to it.
