LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 11-20-2007, 11:03 AM   #1
linux_guy
LQ Newbie
 
Registered: Aug 2006
Posts: 9

Rep: Reputation: 0
linux command wrapper


Hi,

I have a properietary linux running on my server. System is
capable of running under low memory conditions.
I have a vi editor available on the system.

I want to create a shell script wrapper over the actual vi command. I
am planning to verify available memory
before launching vi editor. So when somebody types vi command on the
shell prompt, it should invoke my wrapper
then my wrapper would invoke the actual vi editor after verification.

Can somebody let me know what all things I have to change in the
system in order to make this setup work.

Thanks in advance,
Adil
 
Old 11-20-2007, 11:35 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
I'm sure there are lots of ways to do this.

What I would try first:

In the directory where vi lives, rename vi to (e.g.) "realvi". Then, create a link to your script and name the link "vi". In your script, you would call "realvi"
 
Old 11-20-2007, 01:46 PM   #3
bengoavs
LQ Newbie
 
Registered: Jun 2006
Posts: 20

Rep: Reputation: 0
Quote:
mv /bin/vi /bin/vireal
ln -s (your script path) /bin vi
vireal (your script):
Quote:
#!/bin/bash
freemem=`free -m | grep Mem | awk '{print $3}'`
if [ $freemem -lt (your memory cap) ]; then
echo "not enough memory to run vi"
exit 1
else
vireal $1
fi
 
Old 11-21-2007, 11:01 AM   #4
linux_guy
LQ Newbie
 
Registered: Aug 2006
Posts: 9

Original Poster
Rep: Reputation: 0
thanks for the replies

This seems to be easier than I thought....

Any idea if we can proxy some of the shell builtins in the similar way.

Thanks,
Adil
 
  


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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is a command wrapper? johnsanty Programming 5 09-22-2006 02:19 PM
NDIS Wrapper Help Please FuGeE Linux - Wireless Networking 1 12-11-2004 11:14 AM
OS Wrapper ines Linux - Software 10 11-04-2004 06:57 AM
FTP wrapper dominant Linux - Security 9 03-25-2004 03:34 AM
ndis wrapper citrus Linux - Hardware 3 01-08-2004 06:10 AM


All times are GMT -5. The time now is 03:03 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