replace spaces with underscores for partition label
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
work fine in the command line, yet it stops in the script. Well to be fair, I don't know what it is doing, as it shuts down the terminal window as soon as enter is hit. This is very strange.
work fine in the command line, yet it stops in the script. Well to be fair, I don't know what it is doing, as it shuts down the terminal window as soon as enter is hit. This is very strange.
Code:
# sets all chars to CAPs,
# just incase the user forgets or does not do what is needed,
# this is part of error handing.
# it ensures proper formatting of the data you need to work with.
event=${event^^}
#and
#replaces all spaces with an underscore
event=${event// /_}
{var//search pattern/replace with}
Code:
${var^^} #sets chars to caps
${var,,} #sets chars to lower case
your terminal goes away, closes, is no more every time you run your script?
Code:
GNU nano 2.2.6 File: formatusb.sh
#/bin/bash
that is what you had in your script in this post eairer. your first line needs to go away or put it under the crunch bang/bin/bash
which is missing the bang btw, it needs to look like this
Code:
#!/bin/bash
that is the proper format it always goes top line right on the left side border in order for a BASH script to work
Right then, I think I've found the problem, it all works perfectly but not from the desktop shortcut. Which is this:
Code:
[Desktop Entry]
Name=Format USB
Comment=Script to format 64Gb usb drive to FAT32
Icon=/usr/share/my_icons/formatusb.png
Exec=lxterminal -e /home/pi/Documents/bash_scripts/format.sh
Type=Application
Terminal=False
I have tried setting Terminal to True, but it still closes down as soon as you press enter to input the name. I have also tried to use zenity to ask the question to see if that would work, but now it just closes the terminal window straight away.
What am I missing here, having this run from a simple desktop icon is essential for this program.
Right then, I think I've found the problem, it all works perfectly but not from the desktop shortcut. Which is this:
Code:
[Desktop Entry]
Name=Format USB
Comment=Script to format 64Gb usb drive to FAT32
Icon=/usr/share/my_icons/formatusb.png
Exec=lxterminal -e /home/pi/Documents/bash_scripts/format.sh
Type=Application
Terminal=False
I have tried setting Terminal to True, but it still closes down as soon as you press enter to input the name. I have also tried to use zenity to ask the question to see if that would work, but now it just closes the terminal window straight away.
What am I missing here, having this run from a simple desktop icon is essential for this program.
Kind regards
iFunc
it might be because it does not take that long to run it period, try it striaght off the command line and see how long it takes your PC, with mine it was like a millisecond to complete the action, because it is set to run that script after it is complete it no longers needs to be open (the Term). In other words the way you have it set it is doing what it is suppose to be doing.
It's just really strange that it runs perfectly without those two lines correcting the input, I just don't get it, how can two lines of code conditioning the input string suddenly get the script to shutdown when using a desktop icon. Yet either, run program from command line and it works fine, or remove the two lines and it runs perfectly from the desktop icon. Just does not have any logic behind it that I can get my head around it.
It's not like I am asking the computer to make a cup of tea with milk, I just want to format a usb stick from the double click of a button, there must be a way to do this!
It's just really strange that it runs perfectly without those two lines correcting the input, I just don't get it, how can two lines of code conditioning the input string suddenly get the script to shutdown when using a desktop icon. Yet either, run program from command line and it works fine, or remove the two lines and it runs perfectly from the desktop icon. Just does not have any logic behind it that I can get my head around it.
It's not like I am asking the computer to make a cup of tea with milk, I just want to format a usb stick from the double click of a button, there must be a way to do this!
if it is the same script I do not know, I do not have shortcuts on DT I run i3 WM I use my Keyboard shortcuts so I cannot run it on my system to see what's up. pray someone esle steps in and can help you in your delima
though you could just take a good look at it or post it
Thanks very much for all your help BW, you have cleared up lots for me, ultimately, I am just going to have to post instruction and hope they follow it.
Solved, This is just an update as this has now been solved the issue was due to lxterminal using /bin/sh instead of /bin/bash. ${xxx^^} is a bash thing and doesn't work under the sh shell, so the following line in the desktop shortcut was modified to tell the Exec line to use bash as follows:
Solved, This is just an update as this has now been solved the issue was due to lxterminal using /bin/sh instead of /bin/bash. ${xxx^^} is a bash thing and doesn't work under the sh shell, so the following line in the desktop shortcut was modified to tell the Exec line to use bash as follows:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.