Find the answer to your Linux question:
Results 1 to 5 of 5
Hi all I am confused . When SUSE linux is loaded in an embedded bord , how usual controlcommands are writen like IF, WHILE, SWITCH . Does LINUX offer such ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2012
    Posts
    5

    Confused


    Hi all

    I am confused .

    When SUSE linux is loaded in an embedded
    bord , how usual controlcommands are writen
    like IF, WHILE, SWITCH .

    Does LINUX offer such commands ?

    If yes where online SUSE commands ore offered
    for refference ?

    Elico

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    those commands are typically built-in functions of a shell, such as Bash or C-Shell. for example, you could write a bash script using some of those functions like this:

    Code:
    #!/bin/bash
    max=5
    i=1
    while [ $i -le $max ]; do
      echo $i
    
      if [ $i -eq $max ]; then
        echo This is the end
      fi
      i=$(( $i + 1 ))
      sleep 1
    done
    copy that code to a file, e.g., named "test.sh", make it executable:

    Code:
    chmod +x ./test.sh
    then execute it:

    Code:
    ./test.sh
    To read more on the functions in Bash, read the man page:

    Code:
    man bash
    The switch function is available in the C-shell (csh, tcsh, etc.), although you can emulate the functionality in bash. Read up on it in the tcsh man page:

    Code:
    man tcsh

  3. #3
    Just Joined!
    Join Date
    Sep 2012
    Posts
    5
    In case of C language code is writen and cross compiled
    to deploy on the linux based board, how LINUX threads and tasks
    are includded in that C code ?

    do we include LINUX heder files at design time in the C code ?

    Elico

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    Okay, C programming. There is lots of documentation for that at your disposal. See this GNU article on using the getopt function, which also displays the switch function in action:

    Example of Getopt - The GNU C Library

    At the top of the example program there, you will see header include files at the top of the code, containing functions, etc. called within the program.

  5. #5
    Just Joined!
    Join Date
    Sep 2012
    Posts
    5
    Thanks
    Elico

Posting Permissions

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