Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 21 Oct 2014, 01:25
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
My Bash script won't run
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [4 Posts]  
Author Message
piratesmack


Joined: 16 Sep 2009
Posts: 100

PostPosted: Sun 11 Oct 2009, 20:39    Post subject:  My Bash script won't run
Subject description: command not found
 

Whenever I try to run my script, I get " : command not found"
I can't figure out what's causing it

Here's the script
Code:

#!/bin/bash
#pkg2pet convert deb or rpm to pet

pkgtypefunc() {
 local PKG="$1"
 BASENAME=$(basename "$PKG")
 PKGTYPE="${BASENAME##*.}"
 case $PKGTYPE in
  deb)
   echo Found Debian package: $BASENAME
  ;;
  rpm)
   echo Found RPM package: $BASENAME
  ;;
  *)
   echo Unknown/unsupported package: $BASENAME
   exit 1
  ;;
 esac
}

DIALOG="Xdialog"
[ -z "$DISPLAY" ] && DIALOG="dialog"

if [ "$#" = "0" ]; then
 ARGS=$($DIALOG --stdout --title "Select a package" --fselect $HOME 0 0)
 RET=$?
 case $RET in
  0)
   #do nothing
  ;;
  *)
   exit $RET
  ;;
 esac
else
 ARGS="$@"
fi

for PKG in $ARGS; do
 if [ ! -e "$PKG" ]; then
  echo $PKG not found
  exit 1
 fi
 pkgtypefunc "$PKG"
 case $PKGTYPE in
  deb)
   PETNAME="${BASENAME%%.deb}"
   TMP="/tmp/$PKGTYPE/$PETNAME"
   mkdir -p "$TMP"
   dpkg-deb -x "$PKG" "$TMP" || exit 1
  ;;
  rpm)
   PETNAME="${BASENAME%%.rpm}"
   TMP="/tmp/$PKGTYPE/$PETNAME"
   mkdir -p "$TMP"
   ( cd "$TMP" || exit 1
   rpm2cpio "$PKG" | cpio -vid || exit 1
   )
  ;;
 esac
 ( cd "$TMP" || exit 1
 echo \
 "PETMENUDESCR=''
 PETOFFICIALDEPS''
 PETREGISTER='yes'" \
 > $PETNAME.pet.specs
 cd ..
 tar -cvzf "$PETNAME.tar.gz" "$PETNAME"
 tgz2pet "$PETNAME.tar.gz"
 )
done

Last edited by piratesmack on Mon 12 Oct 2009, 15:28; edited 3 times in total
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4353

PostPosted: Sun 11 Oct 2009, 22:37    Post subject:  

If you modified your permissions to make it executable then the next step is to put echo 1 ..... echo 999 throughout the code and see where it is. That's my crude bash debugging technique - similar to assert() in C programs.
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3380
Location: Oregon

PostPosted: Sun 11 Oct 2009, 22:49    Post subject:  

If I may ask, why not use deb2pet.rpm2pet-0.0.4.pet?
deb2pet.rpm2pet-0.0.4.pet
Description  Converts RPM and DEB packages to PETs
pet

 Download 
Filename  deb2pet.rpm2pet-0.0.4.pet 
Filesize  968 Bytes 
Downloaded  435 Time(s) 
Back to top
View user's profile Send private message 
piratesmack


Joined: 16 Sep 2009
Posts: 100

PostPosted: Mon 12 Oct 2009, 15:25    Post subject:  

Thanks, guys.

The problem was being caused by my text editor (programmers notepad)
I copied and pasted the text into geany and it worked
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0516s ][ Queries: 12 (0.0078s) ][ GZIP on ]