Find the answer to your Linux question:
Results 1 to 3 of 3
i'm writing shell script in this below.but i want to programing with c on linux that working same shell script. Code: #!/bin/sh ####shellscript example#### function chat_block(){ /usr/local/bin/naxclassv1 access echo > ...
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    84

    Help me please for covert shell script to c.

    i'm writing shell script in this below.but i want to programing with c on linux that working same shell script.

    Code:
    #!/bin/sh
    ####shellscript example####
    
    function chat_block(){
    /usr/local/bin/naxclassv1 access echo > /etc/squid/squid.conf
    /usr/local/bin/naxclassv1 access cat /usr/local/bin/chat_template/$1 > /etc/squid/squid.conf
    }
    function check_mac_dup(){
    /usr/local/bin/naxclassv1 access cat /usr/local/bin/nax_temp/$1 | grep -w $2 | cut --delimiter=' ' -f 1
    }
    }
    function firewall_safe(){
    IPT="/usr/local/bin/naxclassv1 access iptables"
    
    $IPT -F
    $IPT -Z
    $IPT -X
    $IPT -t mangle -F
    $IPT -t mangle -Z
    $IPT -t mangle -X
    $IPT -t nat -F
    $IPT -t nat -Z
    $IPT -t nat -X
    
    $IPT -A POSTROUTING -s 0.0.0.0/0.0.0.0 -o eth0 -j MASQUERADE -t nat
    $IPT -A PREROUTING -s 0.0.0.0/0.0.0.0 -i eth1 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128 -t nat
    $IPT -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
    $IPT -A FORWARD -i eth1 -j ACCEPT
    }
    
    for arg in "$@"
    do
    # parse $arg
    case $arg
    in
    # match each option with $arg if a match is found proccess the list
    "chat_block") chat_block $2;; 
    "check_mac_dup") check_mac_dup $2 $3;;
    "firewall_safe") firewall_safe;;
    esac
    done
    **i try to use "execl" function in c programing.but not working because i use "|" include in command line. please to help me i want to teach my student in classroom!!.(i don't want to use "shc" command for convert it!!)
    Last edited by bigtomrodney; 06-05-2007 at 02:28 PM. Reason: Added code tags

  2. #2
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    Post moved to the programming/scripting section.

  3. #3
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Try to use the popen() function.
    Google for examples of popen.

    Regards

Posting Permissions

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