Hi
I am currently starting a program from within the terminal, by typing sudo and then the path and name of the program and then start.
If I understand correctly, I should be able to put this single line into gedit, give a .sh extension and run the program by double clicking.
I did try this and it didn't work, I have realised that when I type into terminal, I am prompted for my password and am guessing this is why it doesn't work.
Can anyone suggest a way to overcome this please?
help with a shell script, please
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
help with a shell script, please
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: help with a shell script, please
Wow, that was quick, thank you.
I'm giving it a try now.
I'm giving it a try now.
Re: help with a shell script, please
Sorry, I think I'm being particularyl dim. I can't get it to work
I did try without the 'cd' part and just ./opt/lampp/lampp start and also without the '.' but none of them worked.
Thanks for your help, sorry I'm not getting it.
Okay, the file is now called startxampp with no extension.paradigmX wrote:file extension doesn't matter, you don't even need one
The content of the file isparadigmX wrote: from what I'm hearing, you have 3 problems:
1: your first line has to be a call to the Bash interpretter and should be like thisCode: Select all
#!/bin/bash
3: you either have to have it in a directory the kernel would recognise as for executables or use a ./ in front of your file.
ie.Code: Select all
./<filename>
Code: Select all
#! /bin/bash
cd /opt/lampp
./lampp start
I did this in terminal - it only needs to be done once and not in the file, is that correct?paradigmX wrote: 2: you need to set the permissions on the file to executable, you can do this at the command line by typingCode: Select all
chmod +x <filename>
Thanks for your help, sorry I'm not getting it.
Re: help with a shell script, please
Forgive me for wandering in in the middle of this discussion, but what exactly are you trying to do? I've looked at the contents of your file, and I'm not surprised it didn't work.
#! /bin/bash
cd /opt/lampp
./lampp start
Is incorrect way to start a program the way you intend. If the program is already in your path, or to say in a more simple way: if you can start the program by simply typing its name in an ALT+F3 run dialog then your script should be formatted the same way. Here's an example.
I like to delay the start of avant-window-navigator on my system until everything else has loaded. Here's my shell script to do that:
---------------------------------------
#!/bin/bash
killall avant-window-navigator
sleep 45
avant-window-navigator
---------------------------------------
As is standard, the first line calls the Bash interpretor; the second line kills any previous instance of the program; the third line causes the script to pause for 45 seconds and finally, the last line executes the program. Notice, I don't have the path of the avant-window-navigator; it's not needed because this program is already in my path.
Here's another example:
---------------------------------------
#!/bin/bash
export AWT_TOOLKIT=MToolkit
export HOSTNAME=localhost
/usr/lib/frostwire/runFrostwire.sh
---------------------------------------
In this case, I'm also exporting some variables. Note I needed to specify the patch to the runFrostwire.sh script because this isn't in my path normally.
Please provide me with a more detailed explanation of what you're trying to launch with the script and perhaps we can build a better script to do exactly what you want. Good luck.
#! /bin/bash
cd /opt/lampp
./lampp start
Is incorrect way to start a program the way you intend. If the program is already in your path, or to say in a more simple way: if you can start the program by simply typing its name in an ALT+F3 run dialog then your script should be formatted the same way. Here's an example.
I like to delay the start of avant-window-navigator on my system until everything else has loaded. Here's my shell script to do that:
---------------------------------------
#!/bin/bash
killall avant-window-navigator
sleep 45
avant-window-navigator
---------------------------------------
As is standard, the first line calls the Bash interpretor; the second line kills any previous instance of the program; the third line causes the script to pause for 45 seconds and finally, the last line executes the program. Notice, I don't have the path of the avant-window-navigator; it's not needed because this program is already in my path.
Here's another example:
---------------------------------------
#!/bin/bash
export AWT_TOOLKIT=MToolkit
export HOSTNAME=localhost
/usr/lib/frostwire/runFrostwire.sh
---------------------------------------
In this case, I'm also exporting some variables. Note I needed to specify the patch to the runFrostwire.sh script because this isn't in my path normally.
Please provide me with a more detailed explanation of what you're trying to launch with the script and perhaps we can build a better script to do exactly what you want. Good luck.
Re: help with a shell script, please
Thanks
I'm trying to run Xampp which is an all-in-one program for php/mysql/apache.
to run it from terminal, I type
sudo /opt/lampp/lampp start
I have no idea if /opt is in my path.
I'm trying to run Xampp which is an all-in-one program for php/mysql/apache.
to run it from terminal, I type
sudo /opt/lampp/lampp start
I have no idea if /opt is in my path.
Re: help with a shell script, please
Since you start the program by specifying its path, then try this to make a shell script:
1. Open gedit and paste the following:
#!/bin/bash
/opt/lampp/lampp start
2. Save the file as "start_lampp" (or whatever you like)
3. Right-click on the file; select the 'Permissions' tab and tick the check-boxes for 'execute' for Owner, Group & Others.
4. Next, I'm assuming you're trying to make a handy desktop or panel shortcut. Right-click on your desktop and select 'Create Launcher'
a. Select Type = Application
b. Name = Start lampp (or whatever you like)
c. Command = gksu /path/to/start_lampp
d. Comment = Start lampp application (or whatever you like)
e. Click the large icon button to choose a pleasing icon, or keep the default one.
f. Click 'OK' to save and close. You should now have a new icon on your desktop.
5. Click the new icon; you should be asked for your root password and then the lampp application should start normally.
Let me know if this works.
1. Open gedit and paste the following:
#!/bin/bash
/opt/lampp/lampp start
2. Save the file as "start_lampp" (or whatever you like)
3. Right-click on the file; select the 'Permissions' tab and tick the check-boxes for 'execute' for Owner, Group & Others.
4. Next, I'm assuming you're trying to make a handy desktop or panel shortcut. Right-click on your desktop and select 'Create Launcher'
a. Select Type = Application
b. Name = Start lampp (or whatever you like)
c. Command = gksu /path/to/start_lampp
d. Comment = Start lampp application (or whatever you like)
e. Click the large icon button to choose a pleasing icon, or keep the default one.
f. Click 'OK' to save and close. You should now have a new icon on your desktop.
5. Click the new icon; you should be asked for your root password and then the lampp application should start normally.
Let me know if this works.
Re: help with a shell script, please
Works a treat
Thank you very much
Thank you very much