IT News, Tutorials, Solutions – SYSTEM HALT

Contact

Click here to view my profile

Comments (1) Trackbacks (0)
  1. Hi Thank you so much for your instruction of “Compile C applications with gcc on iOS 4 (iPhone)”
    I follow you instructions and works fine.

    But i have a question can i ask you?
    I just want to run a shell script when iphone start up,
    here is what i do, but sems not work……
    Please help me

    Thanks a lot

    i made a start up shell script test.sh,
    it will generate a file LOG in /var/root

    after reboot i check the LaunchDaements com.xjames “launchctl list|grep xjames”
    it works, but when i check if there is a file LOG in /var/root, there is no LOG

    cat /var/root/hello.c
    #include
    int main()
    {
    printf(“hello, world\n”);
    system(“/bin/sh /var/root/test.sh”);
    return 0;
    }

    cat /var/root/test.sh
    #!/bin/sh
    echo test > /var/root/LOG

    cat /Library/LaunchDaemons/com.xjames.plist

    Label
    com.xjames
    Program
    /var/root/hello
    StandardErrorPath
    /dev/null
    RunAtLoad

    ======================================================================================
    iPhone:~ root# pwd
    /var/root

    ======================================================================================
    iPhone:~ root# ls
    1.sh fake-libgcc_1.0_iphoneos-arm.deb
    11.sh gcc_files/
    Groups_zh_TW.lproj/ gcc_files.tar.gz
    Library/ hello*
    Media/ hello.c
    Preferences/ iconoclasm.178_1.6.2_iphoneos-arm.deb
    STHeiti-Light.ttc include-2.0-sdk-ready-for-iphone/
    STHeiti-Medium.ttc ipod_deb/
    WebClips-3/ sdk-2.0-headers.tar.gz
    WebClips-4/ test.sh
    cBook/

    ======================================================================================
    iPhone:~ root# ls -al hello
    -rwxr-xr-x 1 root wheel 12984 Nov 30 12:11 hello*

    ======================================================================================
    iPhone:~ root# cat hello.c
    #include
    int main()
    {
    printf(“hello, world\n”);
    system(“/bin/sh /var/root/test.sh”);
    return 0;
    }

    ======================================================================================
    iPhone:~ root# cat test.sh
    #!/bin/sh
    echo test > /var/root/LOG

    ======================================================================================
    iPhone:~ root# ls -al hello
    -rwxr-xr-x 1 root wheel 12984 Nov 30 12:11 hello*

    ======================================================================================
    iPhone:~ root# ls
    1.sh fake-libgcc_1.0_iphoneos-arm.deb
    11.sh gcc_files/
    Groups_zh_TW.lproj/ gcc_files.tar.gz
    Library/ hello*
    Media/ hello.c
    Preferences/ iconoclasm.178_1.6.2_iphoneos-arm.deb
    STHeiti-Light.ttc include-2.0-sdk-ready-for-iphone/
    STHeiti-Medium.ttc ipod_deb/
    WebClips-3/ sdk-2.0-headers.tar.gz
    WebClips-4/ test.sh
    cBook/

    ======================================================================================
    iPhone:~ root# ./hello
    hello, world

    ======================================================================================
    iPhone:~ root# ls
    1.sh cBook/
    11.sh fake-libgcc_1.0_iphoneos-arm.deb
    Groups_zh_TW.lproj/ gcc_files/
    LOG gcc_files.tar.gz
    Library/ hello*
    Media/ hello.c
    Preferences/ iconoclasm.178_1.6.2_iphoneos-arm.deb
    STHeiti-Light.ttc include-2.0-sdk-ready-for-iphone/
    STHeiti-Medium.ttc ipod_deb/
    WebClips-3/ sdk-2.0-headers.tar.gz
    WebClips-4/ test.sh

    ======================================================================================
    iPhone:~ root# rm -f LOG

    ======================================================================================
    iPhone:~ root# ls /Library/LaunchDaemons/
    com.openssh.sshd.plist com.xjames.plist

    ======================================================================================
    iPhone:~ root# cat /Library/LaunchDaemons/com.xjames.plist

    Label
    com.xjames
    Program
    /var/root/hello
    StandardErrorPath
    /dev/null
    RunAtLoad

    =======================================================
    iPhone:~ root#reboot now

    ======================================================================================
    iPhone:~ root# ls
    1.sh fake-libgcc_1.0_iphoneos-arm.deb
    11.sh gcc_files/
    Groups_zh_TW.lproj/ gcc_files.tar.gz
    Library/ hello*
    Media/ hello.c
    Preferences/ iconoclasm.178_1.6.2_iphoneos-arm.deb
    STHeiti-Light.ttc include-2.0-sdk-ready-for-iphone/
    STHeiti-Medium.ttc ipod_deb/
    WebClips-3/ sdk-2.0-headers.tar.gz
    WebClips-4/ test.sh
    cBook/

    ======================================================================================
    iPhone:~ root# launchctl list|grep xjames
    - 0 com.xjames


Leave a comment

(required)

No trackbacks yet.