maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   SMS-based stolen phone locator (https://talk.maemo.org/showthread.php?t=60516)

boxhead 2010-08-18 19:25

Re: SMS-based stolen phone locator
 
Quote:

Originally Posted by Sonny_Jim (Post 790907)
Notice that you don't need to write/read a tmpfile, you can just use a backtick. But for some really annoying reason it still isn't working,

p.s You didn't just copy and paste my tar command? I think you might have picked up sms-manager with the wildcard if you did.

No, I didn't copy-paste it.. btw, did you mean to put the 'j' option in the tar command?

digitalvoid 2010-08-18 19:31

Re: SMS-based stolen phone locator
 
Quote:

Originally Posted by AlexV12 (Post 790871)
perhaps ik would be good to combine your programs? sounds like you could help each other allot!

I will post my code soon, it needs some documentation & cleanup.

Sonny_Jim 2010-08-18 19:38

Re: SMS-based stolen phone locator
 
Quote:

Originally Posted by boxhead (Post 790912)
did you mean to put the 'j' option in the tar command?

I meant to put the j in, but forgot to change the file extensions to tar.bz2. You should nearly always use bz2 as it's smaller.

dannym 2010-08-21 13:47

Re: SMS-based stolen phone locator
 
Quote:

Originally Posted by boxhead (Post 790804)
What does 'export' do?

Usually, all your shell variables are known only to the current shell.

If you want the actual _programs_ you start to also get them, you have to export them to the (current process', that is, the shell's) environment first. Once you start another program, it will receive a copy of your environment and thus have a copy of the variable (its name and its value) in there, too.

Actually, I don't know why it makes things better in this situation, because the script uses the shell to expand all the variables to their values anyway - so what use it exporting them if one is already passing them as arguments?

On a slightly off-topic note, the way UNIX processes work is like this:

As far as the kernel is concerned a process is a collection of: process ID, command line arguments, environment, current working directory, process running status, user ID, standard input, standard output, standard error, open files, memory blocks, disk image it was loaded from, other stuff we don't care about.

The first process there is is called "init". It always has PID (process ID) 1.

This "init" process doesn't want to do all the work on its own so it will clone itself (the function is called "fork"), and instruct the clone to do the dirty work. The only thing it does is to wait until the clones die and if so, launch new ones.

This "fork"ing will copy the entire "process" information as-is except for the process ID (will get a new one). This includes the environment variables and that's why they are called "environment" variables :-)

Clones (or more correctly: Processes) can instruct the kernel to load another image, at which point the memory blocks of ITSELF will be filled by loading the new disk image (and the process' command line arguments be updated). Then it executes the function "main" in the newly overwritten memory blocks (the function to do all this is called "exec"). This will not touch environment variables (would usually make no sense).

So the way you can use this is to set some environment variables as early as possible (using "export" in shell or "putenv" in C) and all the other programs started by you (or your children) after that will see them (or at least see copies of them), whether they want to or not (and that later point is the principal difference to arguments).

Note that they can change their copies of the environment variables but they cannot affect their parents (you probably couldn't make rules for your parents either ;-) )

Famous environment variables are
PATH the search path for executables.
HOME the directory where your user data is (i.e. the "home directory").
DISPLAY the display (roughly computer monitor) to display programs on
JAVA_HOME which java VM to use, if anyone wants to use a java VM.

boxhead 2010-08-21 15:10

Re: SMS-based stolen phone locator
 
Thanks for such a thorough explanation, danny. I was wondering why some upstart scripts were using "exec" instead of just running their external processes within script...endscript and now it makes sense.

What doesn't make sense is how no one has reported success for either the original script or the modified one with added "exports" (which shouldn't even doing anything). I've installed it on two different n900s using the same installation steps and it works flawlessly. Can anyone out there confirm that the script works for them?

dannym 2010-08-21 19:35

Re: SMS-based stolen phone locator
 
Quote:

Originally Posted by Sonny_Jim (Post 790740)
Nokia-N900:/etc/event.d# sh banana
: not founde 2:
: not founde 5:
: not founde 6:
: not founde 9:
: not founde 17:
: not founde 22:
banana: line 26: syntax error: "done" unexpected (expecting "do")

I didn't do anything apart from download it from the 1st post, put it into event.d and edit the top of the file

EDIT: I think it needs bash?

Hi...

You have transferred a file (probably from a Windows computer) containing a carriage return (or 30) to the UNIX platform and while Windows ignores it, UNIX actually knows such arcane controls.
Therefore, it actually gives the carriage return to the started process (if it can in fact locate the disk image "foobar<carriage return>".
One can tell by the wonderfully arcane way it overwrote the "line 22" by "<go back to the beginning of the line>: not found". Cute :-)

No, on a more serious note:
Windows (and DOS) text files are like this:
blahblah<carriage return><line feed>
blahblahblah<carriage return><line feed>

UNIX text files are like this:
blahblah<line feed>
blahblahblah<line feed>

Use "dos2unix" or your favourite hex editor (or a decent programmer's text editor) to get rid of the extra carriage returns.

If you are on UNIX, remove them by:
tr -d "\r" <XX >XXX

knypek3 2010-08-24 08:47

Re: SMS-based stolen phone locator
 
Hello!
I have a problem. I send sms with alert code, n900 try to connect to gps. When it connected i don't get any sms and i don't know why. I think i make banana script good.

Quote:

export VALID_IMSI=2600196032***** # this is your own IMSI
export SEND_TEXT_INTERVAL=120.0 # how often (sec) to send SMS
export HOME_PHONE=601123456 # designated phone number to send SMS and phone calls
export TIME_WAIT_TO_CALL=60 # time to wait (sec) after invalid SIM card detected before making phone call
export ALERT_CODE="666" # SMS code used to activate alert mode

The phone numer must be with quotation marks ("") ? Or with country code (+48).
Help me please.
Is there any way to send email also??

Sorry for my english. Waiting for replay.

boxhead 2010-08-24 13:25

Re: SMS-based stolen phone locator
 
Quote:

Originally Posted by knypek3 (Post 796630)
Hello!
I have a problem. I send sms with alert code, n900 try to connect to gps. When it connected i don't get any sms and i don't know why. I think i make banana script good.



The phone numer must be with quotation marks ("") ? Or with country code (+48).
Help me please.
Is there any way to send email also??

Sorry for my english. Waiting for replay.

I thought there might be trouble with non-US phone number formatting. You could try this to test number formatting:

Change HOME_PHONE to 0048601XXXXXX
Change VALID_IMSI to an invalid one
Reboot

If the 0048 prefix works, we can make a small change to the python script to get alert-code SMS working too.

Quote:

Is there any way to send email also??
There's no email function yet.

prankster 2011-04-16 19:49

Re: SMS-based stolen phone locator
 
is there any else phone tracker app in case n900 stolen? simple one ;p
its a bit techy and i dont think so i am capable of doing it..
so any mighty job will be really appreciated.. thanks

Saturn 2011-04-16 20:39

Re: SMS-based stolen phone locator
 
Quote:

Originally Posted by prankster (Post 990100)
is there any else phone tracker app in case n900 stolen? simple one ;p
its a bit techy and i dont think so i am capable of doing it..
so any mighty job will be really appreciated.. thanks

check if this works for you http://wiki.maemo.org/SMSCON

prankster 2011-04-16 20:58

Re: SMS-based stolen phone locator
 
aww its tough to get it all in one day ,atleast to me ..
i bought this phone 3 weeks ago ,hopefully by the time i will be able to do all the good work .
just wanted to have a simple app to locate my cell phone ..anyway thanks
once i saw one app in extra devel ( i am here ) hope you have heard about it ..what do you think about that ? should that be the preference ?

Saturn 2011-04-16 21:38

Re: SMS-based stolen phone locator
 
Quote:

Originally Posted by prankster (Post 990151)
aww its tough to get it all in one day ,atleast to me ..
i bought this phone 3 weeks ago ,hopefully by the time i will be able to do all the good work .
just wanted to have a simple app to locate my cell phone ..anyway thanks
once i saw one app in extra devel ( i am here ) hope you have heard about it ..what do you think about that ? should that be the preference ?

In general avoid the devel, at least until you get some experience with the operating system.
http://wiki.maemo.org/Extras-devel

The "I am here" is unsupported and might give you some trouble to uninstall.
http://wiki.maemo.org/I_am_here

Vertikar 2011-04-17 04:49

Re: SMS-based stolen phone locator
 
Quote:

Originally Posted by prankster (Post 990151)
once i saw one app in extra devel ( i am here ) hope you have heard about it ..what do you think about that ? should that be the preference ?

Smscon is probably a better option - http://wiki.maemo.org/SMSCON

chriju5 2013-02-04 14:28

Re: SMS-based stolen phone locator
 
Quote:

Originally Posted by boxhead (Post 788860)
this script was born out of my rage of having my n900 stolen earlier this year. I wanted a simple sms-based solution for retrieving my new n900 if it were ever stolen again. I used some python code for sms send/recv and gps tracking from the wiki and put it together for this.

here's how it works:
at phone startup, the script reads the sim card number and compares it to your own valid number. If invalid, it'll send an sms every x seconds to a pre-defined phone number that includes imsi and gps coordinates. It also makes a phone call to the same number after a user-defined number of seconds (to lower chance of thief closing out the phone app).

Whether the sim card is valid or not, the script listens for a user-defined sms alert-code. When alert mode is activated, it returns texts to the incoming number with the same info as above (imsi and gps).

installation:
1. Send thief-be-caught.tar.gz to n900
2. Extract: Tar cvf thief-be-found.tar.gz -c /
3. Fill out variables at the top of /etc/event.d/banana
3. Reboot
4. Check if script is running with: Ps | grep sms

prereqs: Python libraries (incl. Python-location)

to close the daemon:
Sh /usr/sbin/sms-quit.sh

notes:
* some alert code strings seem to be interpreted incorrectly by the sms receiving procedure, so try changing the alert code if nothing happens.
* every time the gps coordinates are read, the internal gps and network positioning are enabled in case they were ever disabled. The location server will also be set to supl.google.com.

I hope this helps someone get their phone back if anything unfortunate happens. I am new to sh and python scripting, so please test and improve or offer feedback.

sir,i am new to linux .can you please tell me how to install this app detail by detail like how to extract and change the variable

willi6868 2013-02-04 15:52

Re: SMS-based stolen phone locator
 
Quote:

Originally Posted by chriju5 (Post 1320727)
sir,i am new to linux .can you please tell me how to install this app detail by detail like how to extract and change the variable

Use SMSCon with more features instead. :cool:
http://talk.maemo.org/showthread.php?t=60729
http://wiki.maemo.org/SMSCON


All times are GMT. The time now is 21:08.

vBulletin® Version 3.8.8