Accessing my Droid Maxx from a shell script

Colin Law clanlaw at gmail.com
Tue Dec 29 09:04:29 UTC 2015


On 29 December 2015 at 08:23, MR ZenWiz <mrzenwiz at gmail.com> wrote:

>     indir=$DevicePath/'Internal\\ storage' ### This never works
>     ls $indir
> fi
>
> The line where it has the comment "This never works" - I have tried
> single and double quotes, single and double escape (backslash) in
> every combination that will allow the DevicePath variable to be read,
> and the result is always the same:

To get that showing what you expect use
echo $indir
until it shows what you expect, don't worry about escaping spaces at
this point, just get the string to be
/run/user/500/gvfs/mtp:host=%5Busb%3A003%2C086%5D/Internal storage
then use
ls "$indir"
to do the ls, or anything else you want to do with the name.

>
> mar at marbase:~ $ xtlist
> XT1080 path is '/run/user/500/gvfs/mtp:host=%5Busb%3A003%2C086%5D'
> ls: cannot access
> /run/user/500/gvfs/mtp:host=%5Busb%3A003%2C086%5D/Internal\\: No such
> file or directory

You have not shown us the actual command you entered so can't comment
on why this doesn't work.

> ls: cannot access storage: No such file or directory
>
> But:
>
> mar at marbase:~ $ ls /run/user/500/gvfs/mtp:host=%5Busb%3A003%2C086%5D
> Internal storage/

That is not surprising.

>
> mar at marbase:~ $ ls
> /run/user/500/gvfs/mtp:host=%5Busb%3A003%2C086%5D/Internal\ storage

That is one of the right ways to do it.  You could also just put
quotes round the full name and don't escape the space.

> Alarms/     com.vcast.mediamanager/  kindle/     Pictures/  Vault/
> amazonmp3/  DCIM/     Movies/     Podcasts/
> Android/    Download/     Music/     Ringtones/
> Audible/    Highlight Reels/     Notifications/  SmartVoiceRecorder/
>
> I've tried having the script cd into the directory and it still won't
> list down past the top level "Internal storage."

See my initial comment.

Colin



More information about the ubuntu-users mailing list