JeromePetazzoni :: DerniersChangements :: DerniersCommentaires? :: ParametresUtilisateur :: :: Vous êtes

When I first wanted to upload my little "hello world" program cross-compiled with the ToolChain and statically linked with UcLibC, I noticed that I had a serious problem - there was no way to get the binary to the router ! There is no FTP, TFTP nor anything, client nor server, on the router. The only thing I could use is the telnet server (maybe there's another way ; then let me know!).

The trick is to use echo -ne '\XXX\YYY\ZZZ' >>/var/run/somefile commands thru the telnet interface. To understand how it works, telnet to your router, log in as admin, and run sh. You should get a # prompt instead of the > one. We can only write in /var (it's the only read-write filesystem on the router ; the rest is a CramFs? thing in flash). Now, do the following : echo -ne 'abcd' >>/var/run/hello, then echo -ne 'efgh' >>/var/run/hello ; then if you check the content of the file, with cat /var/run/hello, you will notice that it contains abcdefgh, without added lineskip. Now, do echo -ne '\151\152\153\154' >>/var/run/hello and check the file again : it now caontains abcdefghijkl. The -n flag means "no new-line", because echo usually appends a line break at the end of its output ; the -e flag means "escape sequences", which allow converting \XYZ into an arbitrary character, XYZ being its number - in octal.

Now, it would be really boring to upload the file manually like that, line after line ... Especially if it's a big file. So I wrote a small Python script to do it. Install Python if you don't have it already (apt-get install python should do the trick), and get the script here. Documentation is included in the beginning of the script.

Note : this uploads a file, but it's not executable - yet ! We now have to use the KernelChmod trick.
Il n'y a pas de commentaire sur cette page. [Afficher commentaires/formulaire]