걍 뻘짓이 될지도 모르는데…..
scp 스크립트
if [ $# -eq 4 ]; then scp $1 $2@$3:$4" elif [ $# -eq 2 ]; then scp $1 root@$2:/home/root else echo "$#" echo "Usage: $0 src_file_name target_username target_ip target_path \ $0 filename target_ip" fi
공간나눔
걍 뻘짓이 될지도 모르는데…..
scp 스크립트
if [ $# -eq 4 ]; then scp $1 $2@$3:$4" elif [ $# -eq 2 ]; then scp $1 root@$2:/home/root else echo "$#" echo "Usage: $0 src_file_name target_username target_ip target_path \ $0 filename target_ip" fi
임베디드 개발시에 유용한데… 고정 아이피를 설정해 놓으면 상관 없겠지만 유동일 경우에 여러가지 이유로 인해 ip 바뀐줄 모르고 계속 예전 아이피로 접속하는 헛 삽질을 방지하기 위해 만들어 봤다.
1. /etc/issue 를 /etc/issue.template 으로 복사본을 만든다.
2. /etc/issue.sh 를 다음과 같이 만든다. 파일모드 777 혹은 알아서…
#!/bin/bash cat /etc/issue.template > /etc/issue ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -f2 -d: >> /etc/issue
3. 부팅시 자동실행되게 한다.
* /etc/rc.local 맨 하단에 /etc/issue.sh 실행하게 추가
이 파일이 없거나 작동하지 않는 경우
* /etc/init.d/rc 파일 맨 하단에 /etc/issue.sh 실행하게 추가
이 파일이 없거나 작동하지 않는 경우
* /etc/rc[숫자].d/SXXissue.sh 로 복사
– [숫자] 는 /etc/inittab 에 The default runlevel 에 설정된 숫자 일반적으로 2~5사이임
– SXXIssue.sh 파일명에서 SXX는 XX 에 숫자를 설정할 수 있는데, 랜드라이버가 올라오는 시점 이후에 이 파일이 실행되게 해야 하므로 랜드라이버의 SYY 번호보다 뒷 번호를 사용하면 된다.
예를 들어 랜드라이버가 S40network등등 이라면 S41Issue.sh 라고 등록하면 된다.
Android에서 JSON 데이터를 송수신하기 위해서 HttpURLConnection을 사용하여 만든 함수 입니다.
public static String getJson(String serverUrl, String postPara, boolean flagEncoding) throws Exception {
URL url = null;
HttpURLConnection conn = null;
PrintWriter postReq = null;
BufferedReader postRes = null;
StringBuilder json = null;
String line = null;
json = new StringBuilder();
try {
if (flagEncoding) {
postPara = URLEncoder.encode(postPara);
}
url = new URL(serverUrl);
conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "text/plain");
conn.setRequestProperty("Content-Length",
Integer.toString(postPara.length()));
conn.setDoInput(true);
postReq = new PrintWriter(
new OutputStreamWriter(conn.getOutputStream(), "UTF-8"));
postReq.write(postPara);
postReq.flush();
postRes = new BufferedReader(
new InputStreamReader(conn.getInputStream(), "UTF-8"));
while ((line = postRes.readLine()) != null){
json.append(line);
}
conn.disconnect();
} catch (MalformedURLException ex) {
throw new Exception(ex.getMessage());
} catch (IOException ex) {
throw new Exception(ex.getMessage());
} catch (Exception ex) {
throw new Exception(ex.getMessage());
}
return json.toString();
}
출처 : http://www.jopenbusiness.com/tc/oss/entry/Android에서-Json-사용하여-통신하기-1?category=15
안드로이드 에셋에서 바로 이미지 읽어다가 보여주기
imageview.setImageDrawable( Drawable.createFromStream( getAssets( ).open( “filename.png” ), null ) );
한줄로 퉁~
출처 : http://kmshack.tistory.com/364
개발할때 USB안쓰고 WI-FI로 써야 겠다고 생각!
방법은 아주 간단하다.
ADB 무선 연결 / 무선 접속
일단은 을 USB에 연결 후 TCPIP 포트를 세팅한다.
ADB명령을 통해 포트 7777로 변경한다. (숫자는 아무거나 상관 없음)
#adb tcpip 7777
그리고 이제 USB안녕! 이제 USB 선정리 해버리자!! 폰과 컴퓨터가 같은 네트워크가 연결 된 환경에서 폰의 WIFI주소(설정 – WIFI설정 – 연결된 WIFI를 통해 알수 있음)를 알아서, 아래 명령을 입력 하자.
#adb connect xxx.xxx.xxx.xxx:7777
지저분한 USB안녕?
하지만 베터리 어쩌지…
쓸때만 켜고 제니모션 에뮬레이터를 써야 겠다.
참고로 연결을 끊을때는
# adb disconnect xxx.xxx.xxx.xxx:7777