Home > centOS, Fedora 12, Solaris, Unix/Linux > centOS – shell me

centOS – shell me

Bash/Perl boycot:

I want c/php as my shell scripting, automation ( where i am bored not to use bash/perl/python , how i did that?)

1. ask the system first

[root@shamun rc2.d]# which bash
[root@shamun rc2.d]# which perl
[root@shamun rc2.d]# which php
[root@shamun rc2.d]# which python
[root@shamun rc2.d]# which gcc
[root@shamun rc2.d]# which java
[root@shamun rc2.d]#

so, we use like this:

2. BASH script:

echo “Shamun – are you mad? what is this?”
exit 0;

3. PHP Script:

# Debug user inputs!
echo $argc; print_r ( $argv );
$ret = ‘You didnt input anything type –help’;
$retval = 0;

# Logical statements..!
case ‘status’:
$ret = system(‘service httpd status’,$retval);

case ‘start’:
$ret = system(‘service httpd start’,$retval);

case ‘stop’:
$ret = system(‘service httpd stop’,$retval);

echo ‘service httpd –help or status, start,stop please!!’;

# buffer: flush
echo $ret  . “\r\n”;
# exit script

[root@shamun rc2.d]# service sshd start
[0] => /etc/init.d/sshd
[1] => start
Starting httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
[root@shamun rc2.d]#

4. Perl script
echo ‘my perllllll’

5. python/ruby/c/c++/java the sameway………….


argv array argc variable, logical statement apply.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: