Page 1 of 2 12 LastLast
Results 1 to 10 of 12
Discuss Scripting minicom possible? at the Free Toolchain Software (Cydia App's) - Hackint0sh.org; Does anyone know if it is possible to script interaction with minicom and if yes, ...
  1. #1
    Professional Array

    Join Date
    Apr 2007
    Location
    Gent, Belgium
    Posts
    56
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    10

    Default Scripting minicom possible?

    Does anyone know if it is possible to script interaction with minicom and if yes, how?

    I would like to write some small script to solve the voicemail notification problem for me. That script would then run as a cron job, or launchDaemon (running every 5 or 10 minutes). It should work like this:
    - check if there is a SMS on the SIM card
    - compare it to the last one saved (e.g. to /tmp)
    - if different, use erica's doAlert to show a popup and save the SMS to /tmp

    Quick and easy, but the only part missing is the polling of the SIM card for new SMS messages. I know this can be done through minicom and /dev/tty.debug, but as I am not a C or objC programmer, I cannot just use the code from inside for example aSMS and modify it to my wishes...

    Any advise or help is welcome!



  2. #2
    Senior Professional Array

    Join Date
    Sep 2007
    Posts
    148
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    16

    Default

    yes this is possible. Run minicom with the -S option. Then after you are done, you need to issue a killall minicom (I think with the -9 option). I will try to find some example script for you.
    =============================================
    Help stop the persecution of Falun Dafa in China!
    Stop organ harvesting from living people in China's labor camps
    http://www.faluninfo.net
    http://www.theepochtimes.com/211,111,,1.html
    =============================================
    Falun Dafa, an ancient Chinese self-cultivation practice,
    based on the principles of
    * Truthfulness * Compassion * Tolerance *
    http://www.falundafa.org
    =============================================

  3. #3
    Professional Array

    Join Date
    Apr 2007
    Location
    Gent, Belgium
    Posts
    56
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    10

    Default

    Did a first try today to query the /dev/tty.debug for the last incoming SMS message and it worked, but after it printed the message to minicom, I seem to be unable to do anything else. I have to reboot the iPhone to be able to send new commands to the tty.debug through minicom.

    Anyone know how to decently "close" the connection so I wouldn't have to reboot the phone? Would certainly help in any development of my ideas

    Thanks in advance!

  4. #4
    Senior Professional Array

    Join Date
    Sep 2007
    Posts
    148
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    16

    Thumbs up

    Quote Originally Posted by Tego View Post
    Did a first try today to query the /dev/tty.debug for the last incoming SMS message and it worked, but after it printed the message to minicom, I seem to be unable to do anything else. I have to reboot the iPhone to be able to send new commands to the tty.debug through minicom.

    Anyone know how to decently "close" the connection so I wouldn't have to reboot the phone? Would certainly help in any development of my ideas

    Thanks in advance!
    I have had the same problems with running minicom on /dev/tty.debug. Mine doesn't get any further than the opening screen. Not even the initialization string gets send.

    I suggest running your script on /dev/tty.baseband. You will need to unload the commcenter first, then run minicom -S yourscript (script mode). At the end of the script you need to issue a killall -9 minicom which will kill minicom without hanging up the modem (see also the PDF mentioned below). Then don't forget to restart the commcenter after that.

    Regarding scripting for minicom, if you are on unix/mac/cygwin, look at the man pages for minicom (man minicom) and for scripting specifically, you can also look at the man pages for runscript: man runscript.

    Another scripting example can be found from page 71 and up in the following PDF:

    www.princeton.edu/~vlenders/publications/reports/TIKReport163.pdf

    Hope this helps.
    =============================================
    Help stop the persecution of Falun Dafa in China!
    Stop organ harvesting from living people in China's labor camps
    http://www.faluninfo.net
    http://www.theepochtimes.com/211,111,,1.html
    =============================================
    Falun Dafa, an ancient Chinese self-cultivation practice,
    based on the principles of
    * Truthfulness * Compassion * Tolerance *
    http://www.falundafa.org
    =============================================

  5. #5
    Rookie Array

    Join Date
    Sep 2007
    Posts
    14
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    Guys how did you manage to run scripts . As far as I know you need the "runscript" application to execute your scripts... If so can you send me the file.... Because I have searched everywhere and could not find the correct one..

    Koray


  6. #6
    Professional Array

    Join Date
    Apr 2007
    Location
    Gent, Belgium
    Posts
    56
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    10

    Default

    PmgR: Problem is I don't want to shut down the commcenter, as I want to have a working phone whilst checking for the new SMS messages... Didn't have time to do more tests yesterday evening, will see when I can experiment some more. I found some perl example to be run on the iPhone - maybe I can try it that way instead of using minicom (perl opens port to /dev/tty.debug). Only drawback is that the perl package uses around 10 Mb of precious iPhone space.

    koraybirand: I am not yet at the stage of scripting the minicom - first checking my options

  7. #7
    Rookie Array

    Join Date
    Sep 2007
    Posts
    14
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    OK Tego .. Once you are at the stage of scripting and solve the runscript problem that I am having. Please keep me in mind

    Koray

  8. #8
    Senior Professional Array

    Join Date
    Sep 2007
    Posts
    148
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    16

    Default

    Quote Originally Posted by Tego View Post
    PmgR: Problem is I don't want to shut down the commcenter, as I want to have a working phone whilst checking for the new SMS messages... Didn't have time to do more tests yesterday evening, will see when I can experiment some more. I found some perl example to be run on the iPhone - maybe I can try it that way instead of using minicom (perl opens port to /dev/tty.debug). Only drawback is that the perl package uses around 10 Mb of precious iPhone space.

    koraybirand: I am not yet at the stage of scripting the minicom - first checking my options
    Tego: if minicom hangs with the /dev/tty.debug, you can open another ssh window and then do a killall -9 minicom (the -9 won't hang up the modem) or a kill -9 minicom_pid.

    Please post a copy of the perl script that accesses the modem.
    =============================================
    Help stop the persecution of Falun Dafa in China!
    Stop organ harvesting from living people in China's labor camps
    http://www.faluninfo.net
    http://www.theepochtimes.com/211,111,,1.html
    =============================================
    Falun Dafa, an ancient Chinese self-cultivation practice,
    based on the principles of
    * Truthfulness * Compassion * Tolerance *
    http://www.falundafa.org
    =============================================

  9. #9
    Professional Array

    Join Date
    Apr 2007
    Location
    Gent, Belgium
    Posts
    56
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    10

    Default

    If I could just find back that chunk of perl code... It was somewhere online...

    Thomas

    UPDATE: Found it... in my downloads folder


    Code:
    #!/opt/iphone/bin/perl
    ##
    ##  printenv -- demo CGI program which just prints its environment
    ##
    use CGI::Carp qw/fatalsToBrowser/;
    use Encode 'from_to';
    print "Content-Type: text/html; charset=gb2312\n\n";
    
    
    %form_data = &get_data();
    sub get_data {
       local($string, $prev);
       if ($ENV{'REQUEST_METHOD'} eq 'GET') {
          $_ = $string = $ENV{'QUERY_STRING'};
          tr/\"~;/_/;
          $string = $_;
       } else {
          read(STDIN, $string, $ENV{'CONTENT_LENGTH'});
          $_ = $string;
          $OK_CHARS='a-zA-Z0-9=&%\n\/_\-\.@';
          tr/\"~;/_/;
          $string = $_;
       }
       @data = split(/&/, $string);
       foreach (@data)
       {
          if ($_ =~ /\=/i)
          {
             split(/=/, $_);
             $_[0] =~ s/\+/ /g;
             $_[0] =~ s/%(..)/pack("c", hex($1))/ge;
             $prev = $_[0];
             $data{"$_[0]"} = $_[1];
          } else {
             $data{"$prev"} .= "\&$_";
          }
       }
       foreach (keys %data)
       {
          $data{"$_"} =~ s/\+/ /g;
          $data{"$_"} =~ s/%(..)/pack("c", hex($1))/ge;
       }
       %data;
    }
    
    
    $DEBUG=0;
    $PORT=0;
    $HEAD="";
    $DATA="";
    $LASTPN="+86";
    
    sub TRACE{
    #	print @_;
    }
    
    sub irsend{
    	print $PORT $_[0];
    }
    
    sub sendsms{
    	local $PN=$_[0];
    	local $MSG=$_[1];
    	if ( $PN !~ /\+/ ) {
    		$PN = "+86".$PN;
    	}
    	$PN =~ s/\+//;
    	if ( length($PN) % 2 != 0 ) {
    		$PN = $PN."F";
    	}
    	TRACE "PN=".$PN."\n";
    	local @PNN=split(//,$PN);
    	$PN="";
    	for($i = 0; $i < ($#PNN)/2; ++$i){
    		$PN=$PN.$PNN[$i*2+1].$PNN[$i*2];
    	}
    	TRACE "PN=".$PN."\n";
    	from_to($MSG, "gb2312", "ucs2");
    	$DATA="0031000D91".$PN."0008A7".sprintf("%02X",length($MSG)).unpack("H*",$MSG);
    	$DATA=uc $DATA;
    	$HEAD="AT+CMGS=".(length($DATA)/2-1)."\r\n";
    	$DATA=$DATA."\x1a\r\n";
    	TRACE $HEAD."\n";
    	TRACE $DATA;
    	$HEAD1="AT+CMGF=0\r\n";
    	irsend $HEAD1;
    	sleep 1;
    	irsend $HEAD;
    	sleep 1;
    	irsend $DATA;
    }
    
    if ( length($form_data{'msg'}) > 0 && length($form_data{'phone'})>6 )
    {
    	$LASTPN=$form_data{'phone'};
    	open($PORT, "+<", "/dev/tty.debug") or die("fail open");
    	sendsms $form_data{'phone'}, $form_data{'msg'};
    	close($PORT);
    }
    
    print qq~
       <html>
       <head>
       <title>SMS Sender</title>
       <body bgcolor="#FFFFFF">
       <form method="post" action="/cgi-bin/sendsms">
       *˙∫≈:<input name="phone" type="text" value="$LASTPN">
       <p>
    	˚:<br/>
       <textarea name="msg" rows="9" cols="55">$form_data{'convert'}</textarea> </p>
       <p>
       <input type="submit" value="∑"> 
       &nbsp;&nbsp;<input type="reset" value=""> 
       </form>
    ~;
    print "<XMP>".$HEAD."\n";
    print $DATA."\n";
    
    foreach $var (sort(keys(%form_data))) {
        $val = $form_data{$var};
        $val =~ s|\n|\\n|g;
        $val =~ s|"|\\"|g;
        print "${var}=\"${val}\"\n";
    }
    print "</XMP>";
    print qq~
       <hr>
    	Author: unidevel, 23/09/2007
       </body>
       </html>
    ~;
    Not yet tested!
    Last edited by Tego; 11-13-2007 at 11:22 PM.

  10. #10
    Professional Array

    Join Date
    Apr 2007
    Location
    Gent, Belgium
    Posts
    56
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    10

    Default

    Hmmm, SnowBird just let us know on the forum that the 1.1.2 update does fix the voicemail notifications. Should we continue investigating this scripting then or wait a few days for a safe updater to appear?


 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Scripting from lsof output
    By sailor0703 in forum Genuine Mac Support
    Replies: 1
    Last Post: 03-30-2011, 09:00 PM
  2. Help with Terminal Scripting
    By MicroLabrat in forum Using Snow Leopard
    Replies: 0
    Last Post: 01-30-2011, 12:10 AM
  3. Scripting Language for APPLE
    By JayBird in forum Genuine Mac Support
    Replies: 0
    Last Post: 12-29-2008, 09:16 PM
  4. [Scripting] Start up script
    By JN2 in forum Free Toolchain Software (Cydia App's)
    Replies: 4
    Last Post: 06-17-2008, 10:02 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBulletin®
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
Search Engine Friendly URLs by vBSEO
(c) 2006-2012 Hackint0sh.org
All times are GMT +2. The time now is 03:01 PM.
twitter, follow us!