mardi 30 décembre 2014

linux/shell command to control screen brightness in android


I am working on a kiosk project using an android tablet.If there is no input power to the kiosk for a long time then, the tablet will eventually shutdown.In order to auto-reboot the tab when the power comes back I modified the code in my tabs battery animation file(ipod) using:



#!/system/bin/sh
sleep 300
/system/bin/reboot


However,during the sleep period(shown above),the tabs screen remains in the ON state (and hence takes longer retries for the tab to charge and bootup).I need to turn the screen OFF. What is the command I should use prior to the sleep command to turn my tabs screen OFF during the charging/bootup stage. Thanks !



Echoing stdin when running an ed(1) script


Given the following ed script,



$ cat helloworld
a
hello
world
.
,n
,s,o,O,g
,n
Q


I would like to obtain somehow the interactive output



$ ed
a
hello
world
.
,n
1 hello
2 world
,s,o,O,g
,n
1 hellO
2 wOrld
Q
$


instead of the expected



$ cat helloworld | ed
1 hello
2 world
1 hellO
2 wOrld
$


Is that possible, maybe using a third-party utility? Thanks in advance!


Edit: I guess I should add some motivation. I would like to produce some sample ed sessions, and probably save them with script(1). If this process is performed "live", any modifications would basically imply typing the whole tutorial again (bad) or alternatively "figuring out" the output, potentially based on a long editing session (worse).



Concatenate and pass as parameter, bash


Need some help with removing default gateway. For example, there is an IP 192.168.4.15 with default gateway 192.168.4.14. I connect to WLAN with gw 10.0.0.1 and after that I would like do remove previous gw.



IFS='.' read -ra IPARR <<< "$IP"
Gateway="${IPARR[0]}.${IPARR[1]}.${IPARR[2]}.14"
ssh blah@$IP '/sbin/route -v del default gw $Gateway;'
#ssh blah@$IP '/sbin/ip route delete $Gateway dev rndis0;'
#ssh blah@$IP '/sbin/route -n'


Both ways don't work. However, it is possible to remove it if I ssh into machine. My guess is that something wrong with passing $Gateway variable. Any suggestions?



how to find files based on filename range?


I have some files with numeric names: 2341a.po, 4567211someword.po, 0012.po, etc. I would like to find a set of files based on the numeric range. such as [126 - 363].


Normally I use regular expression with find. Any numeric range [N, M] can be composed with two regular expressions larger than N and less than M.


The larger than N:


If N = vxyz, then I first do a match for all value > V000, (V=v+1) with [V-9]\d{3,}


Then match vX00, X=x+1, with v[X-9]\d\d


Then match vxY0, Y=y+1, with vx[Y-9]\d


And last vxy[z-9]


Example:


To match number>=234, I use:



`^(0*([3-9]\d{2,}|2[4-9]\d|23[4-9]))`


The smaller than M:


Based on similar logic we will have:



^(0*(vxy[0-z]|vx[0-Y]\d|v[0-X]\d\d|[1-V]\d\d|\d{1,3}))[^0-9]


With Y=y-1,X=x-1,V=v-1


For example, the follow command will find any file between [253, 326]:



find . -maxdepth 1 -type f -regextype posix-extended -iregex '^\./0*([3-9][0-9]{2,}|2[6-9][0-9]{2,}|25[3-9]).*' -iregex '^\./0*(32[0-6]|3[0-1][0-9]|[0-2][0-9][0-9]|[0-9]{1,2})[^0-9].*'


However, this method is too annoying to handle long numbers. Is there any better and easier way to do this?



Where to download or install cent os 32 bit


i m unable to find 32 bit iso for CentOs. I tried on google it is giving me 64 bit only and in my virtual box 64 option is missing.



VNC into login screen (instead of user's desktop)


I'm using RasPi B+ with Raspian from Noobs, lightdm, lxde




There are various descriptions out there on how to set up TightVNC on a RasPi, most of them VNC into root's desktop or another pre-specified user's desktop. I would like to see the lightdm login screen instead when connecting via VNC. Reasons:



  • flexibility: not being limited to a specific user (especially not root)

  • functionality: those recipes force a user, then use startx or the like, which gives you a slightly crippled lxde session (no permission to mount USB devices, no reboot/shutdown).


I was able to set something like this up using x11vnc, using recipes like:



This starts x11vnc together with lightdm and mirrors the main desktop over to VNC. Drawbacks:



  • performance: x11vnc is considerably slower than tightvnc. I've played with the x11vnc flags for a day, but have to reduce quality a lot to get somewhere near the performance of tightvnc.

  • boot performance: having to boot into lightdm instead of command line adds about 10secs on boot time.

  • CPU load: x11vnc constantly uses about 15-30% CPU


Is there a way to get TightVNC to load the lightdm login screen? I reckon I need to modify the line /usr/bin/lxsession -s LXDE & in ~/.vnc/xstartup, but unsure how. Any help appreciated!



how to transfer 1G big file via TCP in C lanuage


I am a Chinese student, it's my first time to ask question in this site,my English is pool.Now,I need to transfer a big file, for example:1G or larger. how to write C code(Linux-based), or any good idea to transfer a big file which can be successfully received without mistake.Thanks very much!