Ask Your Question
1

Problem with users in a shell script

asked 2015-12-24 06:57:28 -0500

Hello,

I have downloaded this font archive: profont-x11.7z and I've made this script to install it:

#!/bin/bash

su

echo "Start install"
mkdir -p /usr/share/fonts/profont

echo "Extracting 7z File"
7za e profont-x11.7z -o/usr/share/fonts/profont

echo "Entering Font Directory"
cd /usr/share/fonts/profont

echo "Deleting Unnecessary Files"
rm -df LICENSE readme.txt profont-x11/

echo "Installing font"
chmod 644 *.pcf -R
mkfontscale
mkfontdir

echo "Leaving Font Directory"
exit

echo "Done!"
cd -

The problem is the output doesn't show until I enter the exit command on the prompt. I mean, it stays logged as root, and I have to manually exit the su command to make it work. Why is that?

Thank you for your help

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-12-24 10:50:02 -0500

sideburns gravatar image

Welcome to ask.fedora. I'm not sure why you need to create a script to automate a job that you're only going to do once, or why the exit command inside the script isn't enough. You may find more information in this tutorial: http://tldp.org/LDP/abs/html/

My suggestion, if you must use a script, is to take the su and exit out, then create a second script that calls the firs with su -c. That guarantees that you're not still root when it's done.

edit flag offensive delete link more

Comments

Thank you for your answer. I used this script to install several fonts (monotypes for testing on my source editors). Hope I can learn from all of you, guys.

Regards!

damonh gravatar imagedamonh ( 2015-12-30 08:18:22 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-12-24 06:57:28 -0500

Seen: 55 times

Last updated: Dec 24 '15