Wednesday, September 24, 2014

Perforce login with ticket

The perforce server may doesn't accept the actual password as argument with -P option as shown below

bash-3.2$  p4 -u myuser -P mypassword changes -m1
                  Perforce password (P4PASSWD) invalid or unset.

But the password supplied with -P (mypassword) works, if you type it with below command
bash-3.2$ p4 login
Enter password: mypassword

User myuser logged in.

You may need to authenticate to Perforce server from scripts during automation. The alternative way to login is pass the ticket value instead of password with -P option.

How to get the ticket value?

bash-3.2$ p4 login -a -p
Enter password: ******
ABCD1234EFGH5678IJKL1234MNOP5678

You'll get a 32 character length ticket value. Use it as password along with -P

bash-3.2$  p4 -u myuser -P ABCD1234EFGH5678IJKL1234MNOP5678 changes -m1
                   Change 12345 on 2014/09/24 by idiot@idiot_box 'UI bug fix'

The above command works !!

Friday, September 19, 2014

How to extract a specific file from zip?

Lets say I have a zip file "my-archive.zip" and I want to extract only "c.zip" file from it.

First check the zip content with below content

unzip -l "my-archive.zip"

Archive:  my-archive.zip 

  Length      Date    Time    Name
---------  ---------- -----   ----
     2213  09-17-2014 15:57  a.zip
     1591  09-17-2014 15:57   b.zip
     4005  09-17-2014 15:57   c.zip
     6966  09-18-2014 14:07   d.zip
---------                     -------
   13182                     4 files
     

And now to extract only "c.zip"

unzip -j "my-archive.zip" "c.zip" -d tmp

Where it extracted "c.zip" to "tmp" directory