The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell script to catch PL/SQL return values Veera_Raghav Shell Programming and Scripting 1 12-19-2008 05:47 PM
How to launch a Csh shell script using Excel Macro ? Raynon Shell Programming and Scripting 1 11-08-2006 12:22 PM
Return value (int) from main to calling shell flounder High Level Programming 3 09-25-2006 10:14 PM
return variable from PL/SQL procedure to shell ap_gore79 Shell Programming and Scripting 4 06-03-2004 04:49 PM
macro on shell script ? inquirer UNIX for Dummies Questions & Answers 4 08-15-2001 10:31 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-04-2008
sjdolding sjdolding is offline
Registered User
  
 

Join Date: Jul 2008
Location: UK
Posts: 2
Return shell value to a VI macro

Hi,

Have searched around for a solution to this and get frustrating close but have not nailed it.

vi on HP-UX

what I'm trying to do is utilise the key mapping available within Vi to run a shell script which uses awk script to scan the file i'm working on and return the line number or unique pattern (could go either way but the principle im trying to achieve is pass a value back so that vi macro can then utilise it)

The closest ive got via Google is

The most powerful macros, however, are created using programs combined
into shell scripts (or DOS batch files), and acting as filters on the text
sent to them from within vi. Such shell scripts or programs must take standard
input and send results to standard output (which most UNIX tools do).

but guess what no example! I've tried more in hope than expectation to set a map command as follows:

map ^[[O ^[: !line_test^M

where line_test is hard coded to echo out a line number which then can but as expected all it does is echo out the line number and is not interpreted as the line number I wanted to go to.

I subsequently modified the script to exit with a value and then tried to use $?

map ^[[O :!line_test : ^[: $?^M

but get error badly formatted address

any help greatly appreciated.
  #2 (permalink)  
Old 07-07-2008
sjdolding sjdolding is offline
Registered User
  
 

Join Date: Jul 2008
Location: UK
Posts: 2
found it (sort of)

Despite the absence of any reply (not sure if this question was in the wrong place or just didn't interest anybody!) i have found an answer which i will post as I know from past experience that nothing is more frustrating than trawling the Net for something find it and then found its not been followed up.

I managed to achieve my goal by having the external shell script write out the value to a file in /tmp, the macro then read in the file to the current file , deleted the line and assigned it to buffer 'a' and then using the @ notation to pass to the : (go to line) command.

map ^[[O :!goto_func %^M :r /tmp/goto.mac^M "add:@a^M : !rm -f /tmp/goto.mac^M

still a bit cludgy as edits the existing file, (im thinking is there a way of reading directly into the buffer?) if anyone has a more elegant solution then please post it here.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 08:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0