[Q] Need help writing a simple interactive bash script - Android Q&A, Help & Troubleshooting

Long story short, I have some Nexus 7s and ethernet adapters to go with them and need to configure eth0 with a static IP. I have already written scripts that run and configure eth0 with what we need at the moment. The script basically consists of one line that says "ip addr add 192.168.1.5/24 dev eth0". It works great for what we need.
Every once in awhile we need our team to configure custom IPs on eth0 but these guys are even more noob than me, I've just been opening up Terminal and doing the same command from above but with different IP info by hand.
So my question, Could someone with some bash scripting knowledge give me a tip on how to write an interactive script that asks what IP, Netmask, Gateway then runs it with that IP info? It will probably involve echo commands, but again, I'm a noob and was hoping someone here would be able to help. Just a super simple interaction. Nothing too complex. Thanks in advance, also, if I'm posting this in the wrong forum, let me know. Thanks again.

Related

[Question] How to spoof your MAC address?

Anyway to spoof your MAC address on the SGS2?
Tried the standard linux terminal tricks but no joy!
Anyone managed it?
Thanks
Also trying to get this, but no luck so far. I tried using busybox and terminal emulator using this command:
# ip link set eth0 XX:XX:XX:XX:XX:XX
which is supposed to work for other devices,
but i get the message: 'either "dev" is duplicate, or "XX:XX:XX:XX:XX:XX" is garbage'
Any ideas?
HTC Dude said:
Also trying to get this, but no luck so far. I tried using busybox and terminal emulator using this command:
# ip link set eth0 XX:XX:XX:XX:XX:XX
which is supposed to work for other devices,
but i get the message: 'either "dev" is duplicate, or "XX:XX:XX:XX:XX:XX" is garbage'
Any ideas?
Click to expand...
Click to collapse
Never tried this b4, but are you making sure your taking eth0 down 1st? Cause if memory serves in linux, if you don't you can have wierd results.
I take eth0 down first with
# iplink set eth0 down
then
# ip link set eth0 XX:XX:XX:XX:XX:XX
but i still get the error message
'either "dev" is duplicate, or "XX:XX:XX:XX:XX:XX" is garbage'
HTC Dude said:
I take eth0 down first with
# iplink set eth0 down
then
# ip link set eth0 XX:XX:XX:XX:XX:XX
but i still get the error message
'either "dev" is duplicate, or "XX:XX:XX:XX:XX:XX" is garbage'
Click to expand...
Click to collapse
I hate to ask this, but I do have to...
Are you putting XX:XX:XX:XX:XX:XX or a valid address?
johncmolyneux said:
I hate to ask this, but I do have to...
Are you putting XX:XX:XX:XX:XX:XX or a valid address?
Click to expand...
Click to collapse
LOL @ that. Yep, I'm using a valid address, so when it says that it's garbage, i really don't know what it means, because I'm using digits from 0 to 9 and letters from A to F.
Anyone tried this and succeded to spoof it somehow?
HTC Dude said:
LOL @ that. Yep, I'm using a valid address, so when it says that it's garbage, i really don't know what it means, because I'm using digits from 0 to 9 and letters from A to F.
Anyone tried this and succeded to spoof it somehow?
Click to expand...
Click to collapse
Never tried or needed to, whats the purpose?
And does the errors occur when setting? or when bringing UP ?
HTC Dude said:
LOL @ that. Yep, I'm using a valid address, so when it says that it's garbage, i really don't know what it means, because I'm using digits from 0 to 9 and letters from A to F.
Click to expand...
Click to collapse
Sorry mate. Had to ask
johncmolyneux said:
Sorry mate. Had to ask
Click to expand...
Click to collapse
No problemo The errors occur when setting; it just won't allow me to assign a new address because of the said error. (FYI I obtained the information on how to do this from here, but this may be a device-specific problem)
Reasons for doing this can be many, but in my case it's a matter of privacy. I know google is storing al sorts of personal info using MAC addresses (see this for e.g.) and I can't remember having ever approved of that.
I think a small app that could help us change the MAC address on our device would come in really handy in these modern days, where everything is logged and supervised.
hi,
i think that you are missing the word "address" in your command.
try these:
Code:
ip link set eth0 address XX:XX:XX:XX:XX:XX
ip link set eth0 addr XX:XX:XX:XX:XX:XX
ip link set dev eth0 address XX:XX:XX:XX:XX:XX
ip link set dev eth0 addr XX:XX:XX:XX:XX:XX
i guess that the syntax depends on the version of busybox that you are using.
i hope it helped.
greets
velja_bg said:
hi,
i think that you are missing the word "address" in your command.
try these:
Code:
ip link set eth0 address XX:XX:XX:XX:XX:XX
ip link set eth0 addr XX:XX:XX:XX:XX:XX
ip link set dev eth0 address XX:XX:XX:XX:XX:XX
ip link set dev eth0 addr XX:XX:XX:XX:XX:XX
i guess that the syntax depends on the version of busybox that you are using.
i hope it helped.
greets
Click to expand...
Click to collapse
Thanks! This worked:
iplink set dev eth0 address XX:XX:XX:XX:XX:XX
I was able to spoof the MAC address and connect to the internet. However, the connection is reset only a few seconds after i connect, and the MAC address goes back to original.
No idea why this happens, i feel frustrated now. Thanks to y'all for your help anyway!
Did you solve this I have the same problem.
/Mike
When i try this i get "link object is unknown"
/mike
I dont think anyone has answered this yet.
But for the Galaxy Tab you goto /efs/imei/ folder
and change .nvmac.info (open in text editor)
then reboot..
this changed my mac address for me
dseo80 said:
I dont think anyone has answered this yet.
But for the Galaxy Tab you goto /efs/imei/ folder
and change .nvmac.info (open in text editor)
then reboot..
this changed my mac address for me
Click to expand...
Click to collapse
Hi dseo80:
When reading your note I thought that I finally found a way to spoof my MAC on my Galaxy Tap GT-P1000. I did as you said. I could not edit the file where it was and had to move it rename, edit and rename and move it back. After a reset unfortunatly I still have my original address.
I ham on Gigerbread stock version. What rom/version where you on when you did this?
Thanks for any hint
Spoofing/changing MAC address = questionable from a legal POV (at best; illegal in many situations/jurisdictions). Expect this thread to be closed before you work out how to do it.
Thread closed
While there might be legitimate reasons for spoofing a MAC address, there are lots of guides out there describing the process. We don't need to discuss it here on XDA.

razr temp WiFi MAC?

First of I know this is probably a heated debate question, especially on the ethical side. but my intentions are not for bad so PLEASE, do not talk about the dark side if this. Lets keep it clean on on a positive There are plenty of reasons for good to want to do this.
Ok so I have been wanting to use my laptop and my phone at work but here is the problem. They have allowed my laptop but deny phone. ( im assuming MAC filtering ) If I change the Wifi MAC on my phone to the MAC of my computer then I can use both ( not at same time obviously )
I use terminal emulator and have busybox installed (latest one).
Ok so here is all what i have done and nothing is gotten me to be able to change it. Ive posted my progress on another site so i just copied and pasted it here
Open terminal app in phone and type
type: su
then you get a "#" instead of the normal "$"
type: busybox iplink show eth0 ( i had to use tiwlan0 instead of eth0)
This will show the current MAC address of your phone.
type: busybox iplink set eth0(tiwlan0) 00:00:00:00:00:00
replace 00:00:00:00:00:00 with your required MAC address.
but I found out that on my razr i have to use "tiwlan0" instead of eth0 or wlan0. Now the next issue i came across. When I changed the mac it said
either "dev" is duplicate, or "00:00:00:00:00:00" is garbage
What does that mean and is there a fix?
Ive tried searching for a solution but so far nothing
I don't want to permanently change my wifi mac just temp. Anyone else run into this?
btw im using android version 2.3.6 if it matters.
Next post
Ok i know nothing about kernels etc... but I found this while trolling the net.
CM7 Kernel with mac spoof capabilities - xda-developers
Can Anyone translate this to English for me Posted Image Is this a step closer?
So far everything I type come up with the following (these arnt all that i have tried but these are the ones that i believe are the closest to what I am trying to do) :
#ip link set tiwlan0 address XX:XX:XX:XX:XX:XX = RTNETLINK answers: Operation not supported
#busybox ip link set tiwlan0 address XX:XX:XX:XX:XX:XX = ip: SIOCSIFHWADDR: Operation not supported
*update* After some more trolling I did find this :
w ww.rohitab.com/discuss/topic...d-mac-changer/
I tried to find the file but couldn't. Anyone have some spare time and feel like giving it a whirl? Let me know what you come up with if you do Posted Image
**another update with hopefully progress**
ok so I just type in this:
# busybox ifconfig tiwlan0 hw address XX:XX:XX:XX:XX:XX
and it a new option menu popped up. Im new to all this so im learning as I go. I took a screen shot of it.
http ://w w w.razrforums.com/forum/attachments/droid-razr-development/206d1331027096t-temp-wifi-mac-address-screen_20120306_0139.jpg
Can anyone tell me whats the options here?
Im still new so i couldnt actually post the link of the image

[Q] [SL4A] Importing PHP or Python script from github to execute from command line

Hey all,
This is my first post here because I have been tearing my hair out trying to get this to work on my own, and I hope you all can help.
What I am trying to do is get either nest-api in PHP or pynest in python to run out of SL4A in order to control my Nest thermostat ultimately out of Tasker. Both are found on github, but I can't link to them as I apparently need ten posts to do so. So a google search for "nest-api github" and "pynest github" will have to do I suppose.
I have absolutely no issues getting either to run out of Terminal on my MacBook Air, but for whatever reading the SL4A shell seems to escape my understanding. I would rather have the PHP script work, as it has more options for things I can set, which I like. The problem is I have no idea where to put the nest.class.php on my phone in order for the PHP shell to reference it when running the example.php or any script I write myself. When I put both files in the sdcard/sl4a/scripts folder and try to run either from within either sl4a or sl4a's shell I get a call to undefined function error.
For the python script, I'm not sure how I need to import the module so that I can call it with nest.py at the beginning of my command line prompt and follow it up with the user name and password and so on. I've done everything including trying to create an .egg file, which I've since been told is not necessary, and that I simply have to put it in the /sl4a/scripts folder. That doesn't make sense to me though, as I needed to run the setup.py command on my computer in order to start using it, and the .egg file should be the equivalent of that on the phone, no?
So what I am looking for is the foolproof way to get either a php or python script running through the shell that isn't actually hooking into the Android environment at all, which is what all the writeups I have found in my searching seems to pertain to. Then eventually make sure that they are available in a way that Tasker can call them. I should also note that all this has been done in an emulator through eclipse until this point, as I didn't want to go screwing around with my brand new Nexus 4's file structure until I had the best practice perfected.
Do you helpful folk have any guidance, tips, or insight on how I can get that done? Of course I can provide any other information you might need.
Thanks in advance.
Nest Api on Android using SL4A
I spend hours yesterday trying to do this. Did you ever get some help or figured it out on your own?
I have no idea how to make it work with SL4A I have done this succesfully on my computer.
Hope you can help me.
heytcass said:
Hey all,
This is my first post here because I have been tearing my hair out trying to get this to work on my own, and I hope you all can help.
What I am trying to do is get either nest-api in PHP or pynest in python to run out of SL4A in order to control my Nest thermostat ultimately out of Tasker. Both are found on github, but I can't link to them as I apparently need ten posts to do so. So a google search for "nest-api github" and "pynest github" will have to do I suppose.
I have absolutely no issues getting either to run out of Terminal on my MacBook Air, but for whatever reading the SL4A shell seems to escape my understanding. I would rather have the PHP script work, as it has more options for things I can set, which I like. The problem is I have no idea where to put the nest.class.php on my phone in order for the PHP shell to reference it when running the example.php or any script I write myself. When I put both files in the sdcard/sl4a/scripts folder and try to run either from within either sl4a or sl4a's shell I get a call to undefined function error.
For the python script, I'm not sure how I need to import the module so that I can call it with nest.py at the beginning of my command line prompt and follow it up with the user name and password and so on. I've done everything including trying to create an .egg file, which I've since been told is not necessary, and that I simply have to put it in the /sl4a/scripts folder. That doesn't make sense to me though, as I needed to run the setup.py command on my computer in order to start using it, and the .egg file should be the equivalent of that on the phone, no?
So what I am looking for is the foolproof way to get either a php or python script running through the shell that isn't actually hooking into the Android environment at all, which is what all the writeups I have found in my searching seems to pertain to. Then eventually make sure that they are available in a way that Tasker can call them. I should also note that all this has been done in an emulator through eclipse until this point, as I didn't want to go screwing around with my brand new Nexus 4's file structure until I had the best practice perfected.
Do you helpful folk have any guidance, tips, or insight on how I can get that done? Of course I can provide any other information you might need.
Thanks in advance.
Click to expand...
Click to collapse
I read on ifttt that they are planning on integrating nest options there. SO that is an easier solution I hope happens soon. They said this fall (already gone) or winter they hope to add functionality to for Nest. <fingers crossed>

[Q] Compiling help a noob.

Im writing a Network Scanner currently in Python/Kivy for Android. I could do everything i wanted if i could execute a Python module called Scapy from the shell(Obviously this is a rooted app), but unfortunately its not possible. Atleast not with alot of work and when the App is finished i dont want my users to have to go through installing countless dependencies to get it working!
I've stumbled along a little unix program called Arp-Scan but i cant find a port for Android. I'm not sure how to port this to Android so i can execute it from a shell.
I have no experience with compiling and needless to say this is frustrating the hell out of me! . This one little stumbling block has been plaguing me for 2 weeks. The rest i will be able to do in pure Python, namely PortScanning and such.
The way the Android OS works is that an APK is unable to use raw sockets. But you are allowed to run a shell as root.
I have the option to use Nmap but if there was ever to be a paid version of my app i would have to buy a license and i simply cant afford it.
All i need is to execute a program from shell: like Arp-Scan to obtain an IP and MAC from the LAN.
Any help will be greatly appreciated.
Thanks in advance.

Mac address change on a tv dongle failed. I followed all possible ways i found online

Hello everybody i am not usually posting because most of my problems are always solved in already existing threads.
But in this case:
i have an anonymous TV dongle.
model: gxt_dongle_3188
android version: 4.4.2
rooted: with Kingo Root
Busybox is installed
I need to change my wifi-mac address from 54:e4:bd:9f:bd96 to 00:22:f4:f0:12:88, i know that the first 3 sets are vendor's indicator but i dont care for the possible conflicts that the change may create.
I started trying to use all the mac changing apps from playstore and i had any result, then i used terminal as SU with busybox and in my iplink show list i had not eth0, only wlan0 and p2p0 that looks like having MAC addresses.
Then i used ifconfig wlan0 hw ether [my mac] command and had no errors but in the status option i could not find any changes
I used also similar command sequences i found online.
also i found that i dont have the "efs" folder in my folder system and as i show in many tutorials this folder contains files about mac addresses.
Had anyone a problem like this so he/she can give me some help?
thank you in advance .

Categories

Resources