using adb push to transfer files to an android device
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
using adb push to transfer files to an android device
Hi there!
I ma trying to use this alias to routinely copy a file to my android device (rooted Galaxy 7), my OS is Mint 20.1 Cinnamon.
alias acim=adb push /home/oren/Downloads/???.mp3 storage/0012-4040/audiobooks/'ACIM lessons'
the wildcards mean the file name will always be numbers between 100 - 400
ADB only returns its help screen, with no error.
Running the same command through terminal, without the alias works just fine.
An idea why it wouldn't work as alias?
Any help will be much appreciated
Oren
I ma trying to use this alias to routinely copy a file to my android device (rooted Galaxy 7), my OS is Mint 20.1 Cinnamon.
alias acim=adb push /home/oren/Downloads/???.mp3 storage/0012-4040/audiobooks/'ACIM lessons'
the wildcards mean the file name will always be numbers between 100 - 400
ADB only returns its help screen, with no error.
Running the same command through terminal, without the alias works just fine.
An idea why it wouldn't work as alias?
Any help will be much appreciated
Oren
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: using adb push to transfer files to an android device
You can not create alias if command not working from terminal.
Is the path correct? 'hero2lte:/storage/0012-4040/audiobooks/ACIM lessons'
Is the path correct? 'hero2lte:/storage/0012-4040/audiobooks/ACIM lessons'
Re: using adb push to transfer files to an android device
Edit: To revisit the context, OP's original post had ...
Android directory "ACIM lessons" with a space ...
Code: Select all
alias acim='adb push /home/oren/Downloads/???.mp3 hero2lte:storage/0012-4040/audiobooks/ACIM lessons'
Last edited by Welcome on Thu Mar 04, 2021 12:11 pm, edited 2 times in total.
Re: using adb push to transfer files to an android device
Thank you all for chiming in!
As 1000 suggested, the path was incorrect ( I edited my original post to reflect the correction)
Now the command works well from the terminal -
oren@oren-V530S-07ICB:~$ adb push /home/oren/Downloads/???.mp3 storage/0012-4040/audiobooks/'ACIM lessons'
/home/oren/Downloads/222.mp3: 1 file p...ed. 10.4 MB/s (514033 bytes in 0.047s)
but still, as alias, I still just get the adb help screen.
As 1000 suggested, the path was incorrect ( I edited my original post to reflect the correction)
Now the command works well from the terminal -
oren@oren-V530S-07ICB:~$ adb push /home/oren/Downloads/???.mp3 storage/0012-4040/audiobooks/'ACIM lessons'
/home/oren/Downloads/222.mp3: 1 file p...ed. 10.4 MB/s (514033 bytes in 0.047s)
but still, as alias, I still just get the adb help screen.
Re: using adb push to transfer files to an android device
Try something like this add
Reload the base
( However I don't know where you want save alias. I guess that you added alias in ~/.bashrc file )
and test acim command.
Code: Select all
###########################{
MY_ACIM(){
adb push /home/oren/Downloads/???.mp3 storage/0012-4040/audiobooks/'ACIM lessons'
}
# USAGE: acim
alias acim='MY_ACIM'
###########################}
Code: Select all
source ~/.bashrc
and test acim command.
Last edited by 1000 on Tue Mar 02, 2021 2:46 pm, edited 2 times in total.
Re: using adb push to transfer files to an android device
This works perfectly!
Thanks a lot!
Thanks a lot!
Re: using adb push to transfer files to an android device
It's not properly quoted. This should work:
Code: Select all
alias acim='adb push /home/oren/Downloads/???.mp3 storage/0012-4040/audiobooks/ACIM\ lessons'
I'm also Terminalforlife on GitHub.
-
- Level 16
- Posts: 6054
- Joined: Mon Aug 27, 2012 10:17 pm
Re: using adb push to transfer files to an android device
Thinking about it, rather than telling you it's wrong, it'd be better to explain why. So let's look at what you typed:
The shell, not too surprisingly, typically reads from left-to-right (exceptions are well outside the scope of this thread). The shell, therefore, will first see
After
The reason what I posted should work, is because it keeps the entire command you want assigned to the
You might've noticed I changed your
Hope that helped, or at the very least was interesting to you and/or passers-by.
Code: Select all
alias acim=adb push /home/oren/Downloads/???.mp3 storage/0012-4040/audiobooks/'ACIM lessons'
alias
, which is a BASH builtin, meaning it's built into the shell. I'm assuming you're using BASH, by the way. You probably have an idea what alias
does, because you're using it right there. After
alias
, the shell will see the acim=adb
word (shell's idea of a word) which alias
interprets to mean that acim
is to be the name associated with the alias, and it equals the value of adb
. However, then it sees the rest: a series of out-of-place words which appear as though they were additional arguments to the alias
builtin. As expected, the builtin errors out.The reason what I posted should work, is because it keeps the entire command you want assigned to the
acim
alias together, as part of the one argument, which is in the syntax of alias NAME=COMMAND.You might've noticed I changed your
'ACIM lessons'
to ACIM\ lessons
; that's because the shell would get confused seeing multiple pairs of apostrophes (AKA: single-quotes). It works because I've escaped the space, effectively stopping the shell (when you actually use the alias) from interpreting ACIM
(and stuff before it) and lessons
as two separate fields.Hope that helped, or at the very least was interesting to you and/or passers-by.
Last edited by Termy on Thu Mar 04, 2021 11:03 am, edited 1 time in total.
I'm also Terminalforlife on GitHub.
Re: using adb push to transfer files to an android device
Thank you very much for this elaborate and insightful reply.
It not only helped by solving the problem; It will surely be very useful in future attempts to write commands, aliases etc.
All the very best!
It not only helped by solving the problem; It will surely be very useful in future attempts to write commands, aliases etc.
All the very best!
Re: using adb push to transfer files to an android device
That puts a nice big smile on my face. Happy to help!
I'm also Terminalforlife on GitHub.