[SOLVED] [Bash] why isnt this script working ? Pop!_OS
by ////// from LinuxQuestions.org on (#6J4MZ)
i have a startup script that used to work with my Arch install but for some reason it wont run anymore when i try to use it on my Pop!_OS installation.
Code:root@pop-os:/home/vile# sh /usr/local/bin/setup.sh
/usr/local/bin/setup.sh: 3: function: not found
/usr/local/bin/setup.sh: 6: [[: not found
Conky is already running.
/usr/local/bin/setup.sh: 18: Syntax error: "}" unexpected
root@pop-os:/home/vile#
PHP Code:#!/bin/bash
functionConky1{
pid=$(pgrepconky1)
if[[-z"$pid"]];then
echo"StartingConky1."
cd/home/vile/conky/auzia-conky
/usr/local/bin/conky1-dcconkyrc&
else
echo"Conkyisalreadyrunning."
fi
}
functionConky2{
pid=$(pgrepconky2)
if[[-z"$pid"]];then
echo"StartingConky.alerts"
/usr/local/bin/conky2-dc/home/vile/conky/conky.alerts&
else
echo"Conky.alertsisalreadyrunning."
fi
}
functionConky3{
pid=$(pgrepconky3)
if[[-z"$pid"]];then
echo"StartingConky.who."
/usr/local/bin/conky3-dc/home/vile/conky/conky.who&
else
echo"Conky.whoisalreadyrunning."
fi
}
functionGuake{
pid=$(pgrepguake)
if[[-z"$pid"]];then
echo"StartingGuake."
/usr/bin/guake
else
echo"Guakeisalreadyrunning."
fi
}
functionPlank{
pid=$(pgrepplank)
if[[-z"$pid"]];then
echo"StartingPlank."
/usr/bin/plank
else
echo"Plankisalreadyrunning."
fi
}
Conky1
sleep1
Conky2
sleep1
Conky3
sleep1
Guake
sleep1
Plank
I just managed to make modifications to that script so that it runs now on my Pop!_OS box.
PHP Code:#!/bin/bash
Conky1(){
pid=$(pgrepconky1)
if[-z"$pid"];then
echo"StartingConky1."
cd/home/vile/conky/auzia-conky
/usr/local/bin/conky1-dcconkyrc&
else
echo"Conkyisalreadyrunning."
fi
}
Conky2(){
pid=$(pgrepconky2)
if[-z"$pid"];then
echo"StartingConky.alerts"
/usr/local/bin/conky2-dc/home/vile/conky/conky.alerts&
else
echo"Conky.alertsisalreadyrunning."
fi
}
Conky3(){
pid=$(pgrepconky3)
if[-z"$pid"];then
echo"StartingConky.who."
/usr/local/bin/conky3-dc/home/vile/conky/conky.who&
else
echo"Conky.whoisalreadyrunning."
fi
}
Guake(){
pid=$(pgrepguake)
if[-z"$pid"];then
echo"StartingGuake."
/usr/bin/guake
else
echo"Guakeisalreadyrunning."
fi
}
Plank(){
pid=$(pgrepplank)
if[-z"$pid"];then
echo"StartingPlank."
/usr/bin/plank
else
echo"Plankisalreadyrunning."
fi
}
Conky1
sleep1
Conky2
sleep1
Conky3
sleep1
Guake
sleep1
Plank
why does that second script work?
my Pop!_OS comes with this bash :
Code:bash is already the newest version (5.1-6ubuntu1).my Arch has this version :
Code:bash 5.2.026-2 (x86_64)is it possible to write that script so that it runs in Pop!_OS and Arch, maybe OpenBSD?
Code:root@pop-os:/home/vile# sh /usr/local/bin/setup.sh
/usr/local/bin/setup.sh: 3: function: not found
/usr/local/bin/setup.sh: 6: [[: not found
Conky is already running.
/usr/local/bin/setup.sh: 18: Syntax error: "}" unexpected
root@pop-os:/home/vile#
PHP Code:#!/bin/bash
functionConky1{
pid=$(pgrepconky1)
if[[-z"$pid"]];then
echo"StartingConky1."
cd/home/vile/conky/auzia-conky
/usr/local/bin/conky1-dcconkyrc&
else
echo"Conkyisalreadyrunning."
fi
}
functionConky2{
pid=$(pgrepconky2)
if[[-z"$pid"]];then
echo"StartingConky.alerts"
/usr/local/bin/conky2-dc/home/vile/conky/conky.alerts&
else
echo"Conky.alertsisalreadyrunning."
fi
}
functionConky3{
pid=$(pgrepconky3)
if[[-z"$pid"]];then
echo"StartingConky.who."
/usr/local/bin/conky3-dc/home/vile/conky/conky.who&
else
echo"Conky.whoisalreadyrunning."
fi
}
functionGuake{
pid=$(pgrepguake)
if[[-z"$pid"]];then
echo"StartingGuake."
/usr/bin/guake
else
echo"Guakeisalreadyrunning."
fi
}
functionPlank{
pid=$(pgrepplank)
if[[-z"$pid"]];then
echo"StartingPlank."
/usr/bin/plank
else
echo"Plankisalreadyrunning."
fi
}
Conky1
sleep1
Conky2
sleep1
Conky3
sleep1
Guake
sleep1
Plank
I just managed to make modifications to that script so that it runs now on my Pop!_OS box.
PHP Code:#!/bin/bash
Conky1(){
pid=$(pgrepconky1)
if[-z"$pid"];then
echo"StartingConky1."
cd/home/vile/conky/auzia-conky
/usr/local/bin/conky1-dcconkyrc&
else
echo"Conkyisalreadyrunning."
fi
}
Conky2(){
pid=$(pgrepconky2)
if[-z"$pid"];then
echo"StartingConky.alerts"
/usr/local/bin/conky2-dc/home/vile/conky/conky.alerts&
else
echo"Conky.alertsisalreadyrunning."
fi
}
Conky3(){
pid=$(pgrepconky3)
if[-z"$pid"];then
echo"StartingConky.who."
/usr/local/bin/conky3-dc/home/vile/conky/conky.who&
else
echo"Conky.whoisalreadyrunning."
fi
}
Guake(){
pid=$(pgrepguake)
if[-z"$pid"];then
echo"StartingGuake."
/usr/bin/guake
else
echo"Guakeisalreadyrunning."
fi
}
Plank(){
pid=$(pgrepplank)
if[-z"$pid"];then
echo"StartingPlank."
/usr/bin/plank
else
echo"Plankisalreadyrunning."
fi
}
Conky1
sleep1
Conky2
sleep1
Conky3
sleep1
Guake
sleep1
Plank
why does that second script work?
my Pop!_OS comes with this bash :
Code:bash is already the newest version (5.1-6ubuntu1).my Arch has this version :
Code:bash 5.2.026-2 (x86_64)is it possible to write that script so that it runs in Pop!_OS and Arch, maybe OpenBSD?