Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parse Command Line
30-05-2012, 07:07 PM, (This post was last modified: 30-05-2012, 07:08 PM by d0lph1n.)
Post: #1
Parse Command Line
aku nk mntak tlong korg sume post code yg korg tulis sndri kt thread nie...

code tu adalah...code ntuk parse command line argument...

digalakkn post code C,perl,php,python,ruby,java,bash sbb yg nie je yg aku reti OK

cntoh code nye :
Quote:./xsxs -v
output --> Version 1.0
./xsxs -a
output --> Display version
anda juga dgalakkn pkai getopt...
Reply
30-05-2012, 10:02 PM,
Post: #2
RE: Parse Command Line
(30-05-2012, 07:07 PM)d0lph1n Wrote: aku nk mntak tlong korg sume post code yg korg tulis sndri kt thread nie...

code tu adalah...code ntuk parse command line argument...

digalakkn post code C,perl,php,python,ruby,java,bash sbb yg nie je yg aku reti OK

cntoh code nye :
Quote:./xsxs -v
output --> Version 1.0
./xsxs -a
output --> Display version
anda juga dgalakkn pkai getopt...

batch boleh ? =)

Code:
@echo off
echo.
echo.
echo.Batch Parsing Command Line
echo.
:$test
if "%1"=="/h" call:help
if "%1"=="/v" call:version
if "%1"=="/author" call:author
if "%1"=="" (
    echo.
    echo.
    echo /h for help
)
goto:end
:help
echo.Batch Example parsing Command Line
echo.syntax: BatchSubstitude.bat /v /author
echo.          /v - show version
echo.          /author - show author
echo.
goto:end
:version
echo.
echo.
echo versi 2.1
echo.
goto:end
:author
echo.
echo.
echo. batch by jackie chan..
echo.
goto:end
:end
[Image: OmDM2yf.png]
Reply
30-05-2012, 10:14 PM,
Post: #3
RE: Parse Command Line
(30-05-2012, 10:02 PM)altenator Wrote:
(30-05-2012, 07:07 PM)d0lph1n Wrote: aku nk mntak tlong korg sume post code yg korg tulis sndri kt thread nie...

code tu adalah...code ntuk parse command line argument...

digalakkn post code C,perl,php,python,ruby,java,bash sbb yg nie je yg aku reti OK

cntoh code nye :
Quote:./xsxs -v
output --> Version 1.0
./xsxs -a
output --> Display version
anda juga dgalakkn pkai getopt...

batch boleh ? =)

Code:
@echo off
echo.
echo.
echo.Batch Parsing Command Line
echo.
:$test
if "%1"=="/h" call:help
if "%1"=="/v" call:version
if "%1"=="/author" call:author
if "%1"=="" (
    echo.
    echo.
    echo /h for help
)
goto:end
:help
echo.Batch Example parsing Command Line
echo.syntax: BatchSubstitude.bat /v /author
echo.          /v - show version
echo.          /author - show author
echo.
goto:end
:version
echo.
echo.
echo versi 2.1
echo.
goto:end
:author
echo.
echo.
echo. batch by jackie chan..
echo.
goto:end
:end

AT LAST...ad gk org yg nk bace thread aku Kih3 ....batch pn aku terima...tq2
Reply
30-05-2012, 11:58 PM,
Post: #4
RE: Parse Command Line
Bash Script:
Code:
#!/bin/sh
if [[ $1 == "-v" ]];
then
        echo "Version 1.0";
elif [[ $1 == "-a" ]];
then
        echo "Display Version";
fi

Result:
Code:
[root@dunia ~]# sh argv.sh -a
Display Version
[root@dunia ~]# sh argv.sh -v
Version 1.0
[root@dunia ~]#
Reply
31-05-2012, 09:17 AM,
Post: #5
RE: Parse Command Line
PHP
PHP Code:
<?php
switch($argv[1]) {
 case 
'-v':
  echo 
'Version 123';
  break;
 case 
'-a':
   echo 
'show version';
  break;
}
?>

;d ;d
puas sudah menanam ubi, nenas juga dibeli orang, puas sudah aku berbakti, pengganas juga dipandang orang

Quote:A true warrior need blood on his sword; A true pirate never afraid to sail the red sea.
Reply
31-05-2012, 12:16 PM,
Post: #6
RE: Parse Command Line
(31-05-2012, 10:27 AM)Muhammad Wrote: C code:

Code:
#include <stdio.h>
#include <stdlib.h>

void usage(void)
{
    printf("Kegunaan yg betul:\n");
    printf("-v ngan -a je lahhhh\n");
    exit (8);
}

int main(int argc, char *argv[])
{

    while ((argc > 1) && (argv[1][0] == '-'))
    {
        switch (argv[1][1])
        {
            case 'v':
                printf("Version 1.0\n");
                break;

            case 'a':
                printf("Display version"\n");
                break;

            default:
                printf("Ini ape nih??: %s\n", argv[1]);
                usage();
        }

        ++argv;
        --argc;
    }
    return (0);
}


Kopi Pes dari tenet Troll 2

ptut la cm prnah tgk LOL
Reply
31-05-2012, 10:29 PM,
Post: #7
RE: Parse Command Line
PHP Code:
:loopme
start explorer
.exe
goto loopme

save as test.bat save as type :all happy hakin9
love u
[Image: bot.gif]

PHP Code:
printf(“Goodbye world \n”); 
Reply
31-05-2012, 11:04 PM,
Post: #8
RE: Parse Command Line
(31-05-2012, 10:29 PM)Tron Wrote:
PHP Code:
:loopme
start explorer
.exe
goto loopme

save as test.bat save as type :all happy hakin9

tu bukn parse command line...apsal la thread aku buat xde yg nk bace OK Sad
Reply
31-05-2012, 11:24 PM,
Post: #9
RE: Parse Command Line
;d aden x tahu ape parse command line
love u
[Image: bot.gif]

PHP Code:
printf(“Goodbye world \n”); 
Reply
01-06-2012, 07:24 PM, (This post was last modified: 01-06-2012, 07:30 PM by Timon.)
Post: #10
RE: Parse Command Line
apa tu ? parse command line dlm c++ wat cane ?
Challenge Accepted
Reply
12-06-2012, 11:44 AM,
Post: #11
RE: Parse Command Line
(01-06-2012, 07:24 PM)Timon Wrote: apa tu ? parse command line dlm c++ wat cane ?
Challenge Accepted

parse command line nie...

untuk run program skali ngn argument...cntohnye rm -rf...rm is the program...-r and -f tu argument...

lau kte run rm sje...die xkn force delete...melainkn kte run rm -f...

bace cnie la nk pham Parse Command Line...lpas pham post code kt thread nie ;b
Reply


Forum Jump: