Thursday, 19 April 2007

STDIN

yesterday, with Ye_Yuan together to try to work out how to decrypt by most stupid way.. however, we find it is impossible to guess this passward, because it need many year. however, it help me to over some UNIX problem.
first is that, I can write script to using STDIN instand of type in by hand. for example, there is a command: smb -U username password servicename. it can lead us into the windows share dirve on Linux service platform. however, when we get into this sharedrive, we need to type command into this program, which means we are in this program. but how can I use script to execute command in sequence? using STDIN. there are two ways, first is like this to write in script:
  1. smb -U zliybsj2 $1 //10.2.1.21/Central_Application_Center <<>
  2. ls
  3. exit
  4. EOF

first, script will using $1 as possward to login Central_Application_Center, then input ls, run it and exit, run again and finish to goto the next command. here EOF is a labell.

another way to write is creating another file, such as com1, we write what we want to do after we get into Central_Application_Center. so, as follow:

  1. smb -U zliybsj2 $1 //10.2.1.21/Central_Application_Center <>

in com1:

  1. ls
  2. exit

There is another way to test when a script or program is runing well by using returning number. as follow:

  1. succ=0
  2. smb -U zliybsj2 $1 //10.2.1.21/Central_Application_Center <>
  3. if [ succ -ed $? ]; then
  4. echo running_well
  5. else
  6. echo some_mistakes_happened
  7. fi

here, $? stands for the retunring number of last program. so if we can complete the left part, such as however to create a pasward, the do this loop to guess, this is the most stupid way to decrypt, if for us time is not a problem. just a joking.

1 comment:

Anonymous said...

大哥看过了,不错,再接再厉啊...