You are not logged in.

#1 2011-03-04 19:39:41

unilx
Member
From: Fredericton,Canada
Registered: 2009-10-01
Posts: 183

Script not working anymore(SOLVED)

I made a basic script and it was working fine for a few hours.I went to work,got back and it stopped working.
I created a folder in  my ~/bin directory and used export PATH=$PATH:~/bin,also i gave the script execution privileges
with chmod 755 pac so I'm not sure where i went wrong .The only thing that comes to mind is that i didn't use chmod u=x pac.
Btw I used echo $PATH and my ~/bin directory was there.As soon as i use the export command again it works

Last edited by unilx (2011-03-05 17:40:18)

Offline

#2 2011-03-04 19:43:40

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: Script not working anymore(SOLVED)

what are the errors? It could be something in the script that might have stopped working. A command or something which changed syntax. Is it a python script? Using python2 and did you upgrade to python 3?

See without knowing what we are dealing with, they are all just shots in the dark !!

Here's a primer on how to post : https://wiki.archlinux.org/index.php/Fo … ow_to_Post


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#3 2011-03-04 20:01:34

unilx
Member
From: Fredericton,Canada
Registered: 2009-10-01
Posts: 183

Re: Script not working anymore(SOLVED)

I'm still a noob at this but i think it's shell scripting,here is my script:
I use pac to execute this one

 1 #!/bin/bash - 
  2 #===============================================================================
  3 #
  4 #          FILE:  pow.sh
  5 # 
  6 #         USAGE:  ./pow.sh 
  7 # 
  8 #   DESCRIPTION:  A script to execute powerpill and do a system,refresh,refresh,update.
  9 # 
 10 #       OPTIONS:  ---
 11 #  REQUIREMENTS:  ---
 12 #          BUGS:  ---
 13 #         NOTES:  ---
 14 #        AUTHOR: 
 15 #       COMPANY: 
 16 #       CREATED: 03/04/2011 04:20:50 AM AST
 17 #      REVISION: 1.0
 18 #===============================================================================
 19 
 20 set -o nounset                              # Treat unset variables as an error
 21 
 22 clear
 23 
 24 echo "Hello unilx"
 25 
 26 date
 27 
 28 sudo pacman-color -Syyu
 29 
 30 echo "System update complete"
 31 
 32 clear
 33 
 34 exit

and pow for this one

  1 #!/bin/bash - 
  2 #===============================================================================
  3 #
  4 #          FILE:  pow.sh
  5 # 
  6 #         USAGE:  ./pow.sh 
  7 # 
  8 #   DESCRIPTION:  A script to execute powerpill and do a system,refresh,refresh,update.
  9 # 
 10 #       OPTIONS:  ---
 11 #  REQUIREMENTS:  ---
 12 #          BUGS:  ---
 13 #         NOTES:  ---
 14 #        AUTHOR: 
 15 #       COMPANY: 
 16 #       CREATED: 03/04/2011 04:20:50 AM AST
 17 #      REVISION: 1.0
 18 #===============================================================================
 19 
 20 set -o nounset                              # Treat unset variables as an error
 21 
 22 clear
 23 
 24 echo "Hello unilx"
 25 
 26 date
 27 
 28 sudo powerpill -Syyu
 29 
 30 echo "System update complete"
 31 
 32 clear
 33 
 34 exit

and this was the error:

bash: pac: command not found

the same with pow
I know both files say pow.sh.It was a mistake that i just noticed now.I used vim pow.sh to start the syntax and renamed it to pow with :w pow

Last edited by unilx (2011-03-04 20:06:59)

Offline

#4 2011-03-04 20:23:58

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Script not working anymore(SOLVED)

unilx wrote:

As soon as i use the export command again it works

What do you export? Post that command.

Offline

#5 2011-03-04 20:25:57

unilx
Member
From: Fredericton,Canada
Registered: 2009-10-01
Posts: 183

Re: Script not working anymore(SOLVED)

export PATH=$PATH:~/bin

Last edited by unilx (2011-03-04 20:26:25)

Offline

#6 2011-03-04 20:27:35

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: Script not working anymore(SOLVED)

put that export command in your .bashrc if its not already there and that should make it work. Make sure to source .bashrc again if you are using a terminal that is already up and running.


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#7 2011-03-04 20:44:10

unilx
Member
From: Fredericton,Canada
Registered: 2009-10-01
Posts: 183

Re: Script not working anymore(SOLVED)

I put that command in .bash_profile,should i remove it from there and just have it in .bashrc.And at the risk of sounding like an even bigger noob what exactly do you mean

Make sure to source .bashrc again if you are using a terminal that is already up and running.

Thx for the info

Offline

#8 2011-03-04 21:00:41

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: Script not working anymore(SOLVED)

You'd better define it the other way around:

export PATH=~/bin:$PATH

This ensures that commands in ~/bin will be found prior to any others. I use it to provide wrapper scripts for stuff called farther down in the path so for instance to always open GVim in a fixed size window for this user:

bp:~/bin$ cat gvim
#!/bin/bash
#
# Silent GVim wrapper

( /usr/bin/gvim -geometry 101x39 $@ &>/dev/null ) &

Moreover I did put the path definition in my ~/.bash_profile:

# Use the commands from .bashrc first.
. $HOME/.bashrc

# Make sure the users bin directory will be searched in the first place from now on.
if [ -d $HOME/bin ]
then
    if [ -d $HOME/neo ]
    then
        export PATH=$HOME/bin:$PATH:$HOME/neo
    else
        export PATH=$HOME/bin:$PATH
    fi
fi

# Make GTK use native windowing (for flash UI elements)
export GDK_NATIVE_WINDOWS=1

These are read from the login shell only, i.e. when the user shell starts first. Thus it orefents from redefining the PATH each time a bash shell is started.


To know or not to know ...
... the questions remain forever.

Offline

#9 2011-03-05 17:39:46

unilx
Member
From: Fredericton,Canada
Registered: 2009-10-01
Posts: 183

Re: Script not working anymore(SOLVED)

Thanks for all the info.I haven't run into any more problems,so i will mark this as solved.

Offline

Board footer

Powered by FluxBB