Find the answer to your Linux question:
Results 1 to 5 of 5
While working on an ARM based embedded system ( TS-TPC-7395 ARM Touch Panel Computer w/ 7-inch TFT-LCD and PoE ) I encountered something weired: there are a couple of commands: ...
  1. #1
    Linux User
    Join Date
    May 2008
    Location
    NYC, moved from KS & MO
    Posts
    251

    commands works only through console on embedded ARM system

    While working on an ARM based embedded system (TS-TPC-7395 ARM Touch Panel Computer w/ 7-inch TFT-LCD and PoE) I encountered something weired: there are a couple of commands: lcd_on, lcd_off in this system that are used to turn on and off the touch screen. The problem is I can only execute them in the shell through the console. If I try to use it via system("lcd_on") in a c program, I got:

    Code:
    sh: lcd_on: not found
    I've checked $PATH, ~/.bashrc, /etc/bash.bashrc but just couldn't find either executable lcd_on or function definition of lcd_on. Also tab completion does not work for those two commands either: As we know in bash after you type in the leading characters of a command, the tab key will bring up all commands starting with the word typed, it's not the case for those two commands. Does anyone know how to locate commands that are not in the $PATH or defined as functions?

  2. #2
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    Perhaps they are builtins. For example:
    Code:
    $ bash -version
    GNU bash, version 3.2.39(1)-release (x86_64-pc-linux-gnu)
    
    $ type -a ssh
    ssh is /home/drl/bin/ssh
    ssh is /usr/bin/ssh
    ssh is /usr/X11R6/bin/ssh
    
    $ type gcc
    gcc is /usr/bin/gcc
    
     $ type printf
    printf is a shell builtin
    See more at help type. Best wishes ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  3. #3
    Linux User
    Join Date
    May 2008
    Location
    NYC, moved from KS & MO
    Posts
    251
    drl,
    Thanks for the detail explanation - I learned something new again. Now I know that's a shell built-in command, is there any way I can call it in my C program?

  4. #4
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    This should give you an idea of the combinations of things that work and don't work. It compares the OS utility printf (/usr/bin/printf) with the bash builtin printf:
    Code:
    #include <stdio.h>
    
    /* t.c - Demonstrate system, bash, command, builtin. */
    
    int main()
    {
    	void slew();
    
    	slew();
    	system("printf ' Hello, world from printf.\n'");
    
    	slew();
    	system("command printf --version");
    
    	slew();
    	system("builtin printf --version");
    
    	slew();
    	system("printf --version");
    
    	slew();
    	system("/usr/bin/printf --version | head -1");
    
    	slew();
    	system(" builtin printf ' Hi there.\n'");
    
    	slew();
    	system(" builtin printf ' Hello, world from builtin printf.\n'");
    
    	slew();
    	system("bash -c \" builtin printf ' Hi there.\n'\"");
    
    	return( 0 );
    
    }
    void slew()
    {
      printf("\n");
    }
    when compiled and executed, produces:
    Code:
     Hello, world from printf.
    
    sh: line 0: printf: --: invalid option
    printf: usage: printf [-v var] format [arguments]
    
    sh: line 0: printf: --: invalid option
    printf: usage: printf [-v var] format [arguments]
    
    sh: line 0: printf: --: invalid option
    printf: usage: printf [-v var] format [arguments]
    
    printf (GNU coreutils) 6.10
    
     Hi there.
    
     Hello, world from builtin printf.
    
     Hi there.
    Best wishes ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  5. #5
    Linux User
    Join Date
    May 2008
    Location
    NYC, moved from KS & MO
    Posts
    251
    Hi drl,
    Thanks for the illustration. Regarding the lcd_on command, I found out it's a function defined in one of the script files. So I create another script wrapper (named LCD_ON) with that function defined:

    Code:
    $ cat LCD_ON
    lcd_on() {
     ...
    }
    lcd_on
    Then I run system("LCD_ON") directly from my c program. Thanks again for the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...