Calling vim shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Calling vim shell script
# 1  
Old 01-11-2010
Calling vim from shell script

Hi All,

I was looking to open a file using vim within shell script. Can someone please suggest a way/syntax for this?

Thanks in advance.

Last edited by jal_capri; 01-11-2010 at 06:48 AM.. Reason: Modifying Title
# 2  
Old 01-11-2010
what exactly are you trying to do?
if you just want to run the vim command from the script, try this

Code:
 
$ cat testfile
This is a test file
 
$ cat vimtest
#!/bin/bash
echo "Opening $1 in vim"
vim $1
echo "Closed $1"
 
$ sh vimtest testfile
Opening testfile in vim
Closed testfile

vi editor will be launched after 1st echo and once you close the editor, script will exit after 2nd echo.
# 3  
Old 01-11-2010
I wanted to run vim -d <file1> <file2> command from a shell script. How can I do that?
# 4  
Old 01-11-2010
you can simply run this command from the script by passing both the arguments.
what problem/error are you facing with this ?
# 5  
Old 01-11-2010
Actually, this is not my intention. I just wanted to check whether redirecting the output of vim -d <file1> <file2> to some file, exports the output in plain text format or it adds some color code related stuff in that? Basically, I wanted to produce colorful difference in a html format.

---------- Post updated at 06:18 AM ---------- Previous update was at 06:05 AM ----------

Please don't bother. I tried it and it shows junk characters.
# 6  
Old 01-11-2010
vim -- you are not expected to run it from a shell script or from something else. It is mainly for interactive things.

You have to take a look at diff, colordiff.
But nothing will produce colorful output to a file. You can use this at terminal, as it is designed for that.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling shell script within awk script throws error

I am getting the following error while passing parameter to a shell script called within awk script. Any idea what's causing this issue and how to ix it ? Thanks sh: -c: line 0: syntax error near unexpected token `newline' sh: -c: line 0: `./billdatecalc.sh ... (10 Replies)
Discussion started by: Sudhakar333
10 Replies

2. Shell Programming and Scripting

calling a shell script present on another server using perl script.

Hi, I am working on a sever A. I want to write a perl script to execute a shell script persent on the server B. please help me in this. thanks in advance. (3 Replies)
Discussion started by: anandgodse
3 Replies

3. Shell Programming and Scripting

How we can pass the argument when calling shell script from perl script

Can someone let me know how could I achieve this In one of per script I am calling the shell script but I need to so one thing that is one shell script call I need to pass pne argument.In below code I am calling my ftp script but here I want to pass one argument so how could I do this (e.g:... (5 Replies)
Discussion started by: anuragpgtgerman
5 Replies

4. Shell Programming and Scripting

run vi/vim encrypted shell script without decryption on multiple servers

Hello Everyone, How do we run vi/vim encrypted shell script without decryption on multiple servers. It is a simple bash script and vim -nx <filename> has been used to encrypt with desired password. Now I have few errors, the syntax is absolutely fine as I have run that script multiple times on... (0 Replies)
Discussion started by: lovesaikrishna
0 Replies

5. Shell Programming and Scripting

Syntax error calling TCL script from shell script

hello everyone i am beginner on shell scripting .and i am working on my project work on ad hoc network i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem " syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies

6. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

7. Shell Programming and Scripting

Calling another shell script

Hi there, I have an script reading content of a file and runs whatever command is specified there, as follows #!/bin/bash # Supposed to read from a file that commands are listed to be run # when the server starts for initialization CMD_FILE=/myScripts/startup/task2do.txt if ; then ... (2 Replies)
Discussion started by: james gordon
2 Replies

8. Shell Programming and Scripting

Calling shell functions from another shell script

Hi, I have a query .. i have 2 scripts say 1.sh and 2.sh 1.sh contains many functions written using shell scripts. 2.sh is a script which needs to call the functions definded in 1.sh function calls are with arguments. Can some one tell me how to call the functions from 2.sh? Thanks in... (6 Replies)
Discussion started by: jisha
6 Replies

9. Shell Programming and Scripting

Calling Shell Script

Hello Friends, I have bash script on unix server which i want to call from windows server. Basically i want a command line which will call this script on unix server. Any one has any idea regarding this? Help really appreciated!! Thanks, Roshni. (1 Reply)
Discussion started by: onlyroshni
1 Replies

10. Shell Programming and Scripting

Calling shell script ?

hi friends, i'm new to unix and straight away i had to start with the script files. I've a script file which gets called from a menu item on a GUI. This script file again calls .awk file, in performing some tasks , which also generates certain files. I modified the files to generate some... (1 Reply)
Discussion started by: Ravi_Kandula
1 Replies
Login or Register to Ask a Question