0

So i am trying to learn how to write scripts for Linux OS's so I wrote this download and install script. Although, I know that any good coder for linux would think this is absolute skid work, It works up to par so far so I just have one error at the moment.

CODE:

#!/bin/sh
###################################
#Lystics Core Linux Code v1       #
#                                 #
# Starting Date 4/14              #
#                                 #
# Ending Date ~                   #
#                                 #
###################################


clear

#Define Veriables
dir='./LysticsCode/'
url='http://lysticscode.host-elite.com/Linux/Bash%20Scripts/LCode.sh'
file=$(basename "$url")

echo LysticsCode for Linux v1 Installer
echo
read -r -p "Are you sure you wish to install? [Y/n] " a
if [ "$a" = 'n' -o "$a" = 'N' ]; then


#Not going to install
echo 'Exiting The Installation. Thank You! =D'
exit 1;
else
#Set up screen
clear
echo LysticsCode for Linux v1
echo First Installation
echo ''
#Installing
echo Downloading Packages...
curl -o "$dir$file" "$url"
echo ''
echo ''
echo 'Download Complete!'
eval "alias lcode=/root/LysticsCode/Main.sh"
exit 1;
fi


#End Script
$SHELL

What I am trying to do is add a command alias that will allow the installed files to be accessed much easier. I tried using eval "alias lcode=DIR" and it did not work. Same with $(alias lcode=dir)

Can anyone Help?

2 Answers2

0

alias doesn't inherit to child process. You should not invoke a child shell at the end of the script, instead, say save your script to a file named myenv.sh, execute you script in current shell as:

. myenv.sh
TieDad
  • 9,143
  • 5
  • 32
  • 58
  • But if the user is in the directory that the file is not located in then at command would not work. But if i were to create an alias for the file located at /root/LysticsCode/Main.sh then it would not matter what directory the user would be in – user2281503 Apr 15 '13 at 07:18
0
$source /root/LysticsCode/Main.sh

Will work.

MangeshBiradar
  • 3,820
  • 1
  • 23
  • 41