LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-12-2007, 04:04 AM   #1
CY83R-R0N1N
LQ Newbie
 
Registered: May 2006
Distribution: CentOS 4.3
Posts: 6

Rep: Reputation: 0
Custom Linux Shell instead of bash/sh


m trying to upgrade the hardware and OS of a really old linux server for a customer.

Everythings good but one this. For the first time ever, this server has custom shells for a specific program they have running the business. Its a courier company this text based menu system to enter details.

This shell is a simple text menu with numerical options. there are multiple users set to use the shell and it appears to be kept in the /bin directory.


file contents:

Code:
BANNERNAME="                                LITE COURIERS"
  MENUNAME="                                  Main Menu"
   
  ##############
  # Functions  #
  ##############
  alias ll="ls -l"
   
  if [ $TERM = "ansi" ]
  then
          echo "- Found ansi terminal.  Forcing to VT100"
          set TERM=vt100
          export TERM
  fi
   
  main_menu () {
  draw_screen
  get_input
  check_input
  if [ $? = 10 ] ; then main_menu ; fi
  }
  #----------------------
  draw_screen () {
  clear
  echo "*******************************************************************************"
  echo "$BANNERNAME"
  echo "$MENUNAME"
  echo "*******************************************************************************"
  echo ""
  echo " 1 - Courier Information System"
  echo
  echo " 2 - Start X Windows (Console Only)"
  echo
  echo " 3 - Command Prompt"
  echo
  #echo " 4 - Start Internet Connection"
  #echo
  #echo " 5 - Stop Internet Connection"
  #echo
  #echo " 6 - Backup to Remote Machine"
  #echo
  echo " x - Log Off"
  echo
  echo
  echo -n " Enter Choice: "
  }
  #----------------------
  get_input () {
  read INPUT
  }
  #----------------------
  check_input () {
  case $INPUT in
       1 )     /cis/cisa.sh
            main_menu;;
       2 )     go_start_X
            main_menu;;
       3 )     bash
            main_menu;;
  #     4 )     touch /tmp/dialup_monitor.startkey
  #          if [ $? = 0 ] ; then echo Executed ; sleep 1
  #          else  echo Uhmm did not work ; sleep 1 ; fi
  #          main_menu;;
  #     5 )     touch /tmp/dialup_monitor.stopkey
  #                if [ $? = 0 ] ; then echo "- Executed" ; sleep 1
  #                else  echo Uhmm did not work ; sleep 1 ; fi
  #          main_menu;;
  #     6 )     /usr/utils/backup_to_remote_machine
  #                if [ $? = 0 ] ; then echo "- Executed" ; sleep 1
  #                else  echo Uhmm did not work ; sleep 1 ; fi
  #          echo "Press any key to continue"
  #          read $TEMP
  #          main_menu;;
       x | X )     clear
            exit;;
       * )     echo "- Bad input.  Try again"
            sleep 2
            return 10;;
  esac
  }
  #----------------------
  go_start_X () {
  if [ "$TERM" != "linux" ]
  then
       echo "- Sorry, your not on the console"
       sleep 2
  else
       startx
  fi
  }
  #----------------------
  ##############
  #   Main     #
  ##############
  main_menu
So anyone had experience getting custom shells working. Im guessing this would use libs to create the semi gui. And it I dont understand what this ANSI/VT100 thing is. I tried just copying the "MENU" file over to the new PC's /bin directory but it gives me "Permission denied" when I try to login to an account using it.

Any help would be a huge help guys

Also, im upgrading from an approx 8 year old redhat distro to CentOS 4.4 so its still redhat.

Last edited by CY83R-R0N1N; 02-12-2007 at 04:08 AM.
 
Old 02-12-2007, 04:59 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,003
Blog Entries: 54

Rep: Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756
So anyone had experience getting custom shells working. Im guessing this would use libs to create the semi gui.
It is a commandline shellscript on the console to present options. No libs necessary, only the scripts and executables it references like "/cis/cisa.sh" and "startx" (also check $PATH).


And it I dont understand what this ANSI/VT100 thing is.
It's a terminal setting which governs how stuff is drawn on the screen.


I tried just copying the "MENU" file over to the new PC's /bin directory but it gives me "Permission denied" when I try to login to an account using it.
To use this as the login shell:
- the script must reside in /bin,
- be executable and have proper access rights,
- the account must have it set in /etc/shells, and
- if you run SELinux check syslog for AVC errors.


Also, im upgrading from an approx 8 year old redhat distro to CentOS 4.4 so its still redhat.
Triple auch! If I would do this I'd first start by verifying the *whole* system before making *any* moves. RHL8 wasn't as vulnerable as the 6 series but still not as good as FC/RHEL are now. Besides, if they kept it at 8 for this long there's bound to be trouble. I wouldn't upgrade but backup for reference, verify stuff that needs to be transferred, set it aside and do a fresh install. That way you start out with a verified sane installation, which means less problems and the the risk of "leftovers" and such will be much less. Just my idea.
 
Old 02-12-2007, 05:58 PM   #3
CY83R-R0N1N
LQ Newbie
 
Registered: May 2006
Distribution: CentOS 4.3
Posts: 6

Original Poster
Rep: Reputation: 0
thanks for the reply.

I did a full backup of the system with rsync onto a USB hard drive no problems.

Then I installed CentOS on the new PC and mounted the USB Drive. SO all the data's now available.

Only problem is recovering all the data to the new system. I have followed the paths in the cis folder thats mentioned in the custom "MENU" shell and restored all that data to its appropriate location.

the big thing right now is just getting the shell to work. Once that works I can look at linking users to the custom cis database. But I cant even log on with that shell. surely a simple shell wouldnt be dependent on the OS???
 
Old 02-13-2007, 06:02 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,003
Blog Entries: 54

Rep: Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756
Thanks for your account of what you did, always interesting.

But I cant even log on with that shell. surely a simple shell wouldnt be dependent on the OS?
However this is not a specific question and it has no relationship to the steps I gave you.
Please either follow those steps of ask specific questions.
 
Old 02-14-2007, 12:01 AM   #5
CY83R-R0N1N
LQ Newbie
 
Registered: May 2006
Distribution: CentOS 4.3
Posts: 6

Original Poster
Rep: Reputation: 0
I fixed it.

weird. I was cheating and using WinSCP to change the files attributes.

I did:

chmod 777 /bin/menu

and hey it works.

Not only that, but I must be bloody lucky. It seems that even though the old PC was so old, after installing the right shared libraries, the program worked without needing to build anything.

DAMN LUCKY!
 
Old 02-15-2007, 05:15 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,003
Blog Entries: 54

Rep: Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756Reputation: 2756
Quote:
I did: chmod 777 /bin/menu and hey it works.
No, you DID NOT FIX IT.
This gives everybody write access to the shell.
That's nice, BUT ITS WRONG.
Change to octal mode 0755.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SUSE Linux- Wine not appearing in shell (right click) or in K menu, installed however digicutkid Linux - Software 1 04-13-2006 11:18 PM
Custom shell menu? Darkfin Linux - Newbie 1 04-24-2005 09:37 AM
Custom Fluxbox Menu TomalakBORG Linux - Software 3 02-27-2005 06:53 PM
Custom yum menu script. GufyMike Fedora 2 05-25-2004 12:38 PM
Custom Gnome Menu semaphore Linux - Newbie 5 03-04-2004 09:08 AM


All times are GMT -5. The time now is 04:21 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration