Showing posts with label basename. Show all posts
Showing posts with label basename. Show all posts

Thursday, January 19, 2012

Print just the name of the running Python program

#!/usr/bin/env python
import sys
import os
for i in sys.argv:
        print i
print sys.argv[0]
print os.path.basename(sys.argv[0].split(".")[0])
#>bin/test.py 56 555
bin/test.py
56
555
bin/test.py
test

Tuesday, May 31, 2011

Slackware SlackBuilds download and install workflow

I'm using Slackware (13.37), and wrote this blog entry to help Slackware newbies like myself understand the workflow dealing with tar files downloaded from http://slackbuilds.org/.

In this example we work with installing the json-py package. The bash scripting is generalized, will work with any package install.

mkdir ~/sources
cd ~/sources
  # [ in browser ] go to http://slackbuilds.org/repository/13.37/python/json-py/
  # [ in browser ] to download Slackbuild json-py.tar.gz, save it to ~/sources 
filename=`basename *.tar.gz .tar.gz`; tar -xf *.tar.gz; rm *.tar.gz; cd $filename;
  # [ in browser ] to download Source download json-py-3_4.zip, save it to ~/sources 
installpkg `./$filename.SlackBuild | grep Slackware | awk '{ print $3 }'`;

The lines of script above give a sense of the workflow. A smarter workflow is provided in the shell script below.

~/sources/eternalDownload.sh 
#!/usr/bin/env bash

while true
do
echo "go to slackbuilds.org and download your SlackBuild tar.gz file, hit enter when done.";
read;
filename=`basename *.tar.gz .tar.gz`; tar -xf *.tar.gz; rm *.tar.gz; 
cd $filename; pwd;
echo "go to slackbuilds.org and download your source code file, hit enter when done.";
read;
installpkg `./$filename.SlackBuild | grep Slackware | awk '{ print $3 }'`;
cd ..;
done