Executing GVIM From Within A Live Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing GVIM From Within A Live Script
# 1  
Old 11-09-2016
Executing GVIM From Within A Live Script

Hey all,
I work in a group environment where multiple people may end up editing the same file. We have measures in place so no two people can edit the same file at once. I have a script that does the following:

call: script file

The script will backup the file,
Moves the file to a safe/busy name, ie: file_in_use (this lets other users know it's busy)
Calls vi to edit it,
I edit the file, then exit vi,
When I exit vi, the script then continues, by
Moving the edited file back to its original name, and
the script exits.

It looks like this bare bones example:

Code:
#protect original file
backup file to archive/bak_file_date
#create alternate file to edit.
mv file file_in_use
#edit the alt file
vi file_in_use
#after exiting vi, rename file to original name
mv file_in_use file
exit



This works brilliantly with vi. But in trying to engage gvim (vim) from within the script, gvim lets the script run its course and exit, then gvim edits "file_in_use," or, effectively, a new file named file_in_use.

When I call vi, it seems to stop or hold up the script until it's done with it, then the script continues with the subsequent steps.

I do not understand how to get gvim to act the same way as vi does.
Or can it?

Thanks in advance.
-Bruce

Moderator's Comments:
Mod Comment edit by bakunin: please use CODE-tags to surround code, data and terminal output. It makes the data stand out and better readable. Thank you.

Last edited by bakunin; 11-09-2016 at 04:26 PM..
# 2  
Old 11-09-2016
Why you would want to use anything instead of vi eludes me. ;-))

I suppose it is because gvim - graphically challenged vi-lookalike - detaches itself from the shell it is run in. Therefore the script continues to run instead of stopping until gvim exits. Use the -nofork option to prevent that.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 3  
Old 11-09-2016
I'm slowly coming around to the 'dark side!' GVIM is a great way to get one used to dabbling in vi. (I have been lured away from EMACS because of GVIM... so I'm hoping to get some credit! LOL.)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

Update: UserCP Screeching Frog 0.7641 - Changed Live Chat to Live Updates

Update: UserCP Screeching Frog 0.7641 - Changed Live Chat to Live Updates In this version of the UserCP, I have changed "Live Chat" to "Live Updates" by disabling the ability to post in the "live chat" area and changed the name to "Live Updates" The reason for this change is that experienced... (6 Replies)
Discussion started by: Neo
6 Replies

2. UNIX for Dummies Questions & Answers

Issue with selecting the text in gvim

Hi, I wanted to select the text in gvim using mouse for coping. some times it works fine and full text will be selected and copied to clipboard if it is like shown in first fig. Paste of the copied text can be done by clicking the middle mouse button. But some times the text will be selected as... (2 Replies)
Discussion started by: twistedpair
2 Replies

3. UNIX for Dummies Questions & Answers

Save and Exit Gvim

Hi, Dummy here! I have a file in my directory named "jest". I wonder why I couldn't save change by using Shift + z + z which I used to do. But it work fine with :wq! command. The second thing is, after several time of accessing the file, I notice my directory appears many files named jest~,... (1 Reply)
Discussion started by: Xierian
1 Replies

4. UNIX and Linux Applications

GVIM with tabs

Hi People, Does gvim latest versions support tabs. I would like to open different files in tabs rather than new windows or split windows. I would like to whether the current version supports it, if it doesn't then how to add such feature. Thanks, :) (2 Replies)
Discussion started by: rimser9
2 Replies

5. UNIX and Linux Applications

Gvim doesn't work properly

Hello All, I am using gvim ( redhat linux machine). backspace doesnot work properly. can some boby suggest a solution ? i have checked with older version. backspace works in it. Thanks Shiv (1 Reply)
Discussion started by: shiv.emf
1 Replies

6. Shell Programming and Scripting

GVIM keyboard shortcuts

Hi all, I am new to linux, can anybody send any link for "GVIM" keyboard shortcuts. (1 Reply)
Discussion started by: balaramaiah.t
1 Replies

7. Windows & DOS: Issues & Discussions

Unix format in gVim

I need to be very careful to keep ^M characters out of files. In gVim, I can change the file format to Unix easily enough, but is there any way to make Unix the default format? I can see "startup options" in the menu, but this takes me to some meaningless config file. I believe my config value... (1 Reply)
Discussion started by: 68ST0X20
1 Replies

8. Solaris

how to add gvim in solaris 5.8

Hi, can someone help me out how to load gvim? I am using solaris 5.8 . (1 Reply)
Discussion started by: adityam
1 Replies

9. Windows & DOS: Issues & Discussions

gVim on Windows

Have you used gVim editor on Windows (xp)? I am talking about the GUI version of vim that you can click the icon on desktop and the gVim editor pops-up and you can create/edit files. Here's my problem: When I use vim editor on cygwin to create/edit files the file creation mask is set to a... (3 Replies)
Discussion started by: milhan
3 Replies

10. Red Hat

Need to get Gvim on Linux enterprise

I have a linux Enterprise Server Version 3 (ES) . It does not have Gvim on it. Can someone tell me how I can get Gvim on it please. I have spent a fair bit of time researching this and have not figured it out. I am probably missing something simple. Frank (1 Reply)
Discussion started by: frankkahle
1 Replies
Login or Register to Ask a Question