Piping to ex from a script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Piping to ex from a script
# 1  
Old 10-11-2007
Piping to ex from a script

Is anyone piping commands to ex from scripts?

echo '%s/change this/to that/\nwq' | ex file.name

I've been using it for years with AIX, Solaris, SGI, with variations ksh and Mandriva and others with pdksh. I've just started using CentOS with ksh and it no longer works. I've tried single quotes double, etc... I've also tried using other shells to no avail. zsh does work, but I don't know how compatible the rest of my scripting would be with it.

I know that Mandriva uses pdksh and CentOS is using AT&T korn shell. I know that there are differences between the two, such as returning variables from subroutines, etc...

I use this type of file manipulation a lot. It's very convenient to be able to change a file without having to create an intermediate file like you would with sed.

Any ideas on why something this simple won't work with AT&T's ksh, or what I need to do to get it working? Or, should I just give in and switch to zsh for the scripts that use ex?

Thanks in Advance.
# 2  
Old 10-11-2007
printf '%cs/change this/to that/\nwq' '%' | ex file.name

# 3  
Old 10-11-2007
If only all of life were that easy

I guess I was looking so hard at the format of the echo statement, I didn't see that it could have been the problem!!! As I read that I heard a very loud "POP" I think it might of been my head coming out of my tail... Smilie

But Like I always say... "I'd rather have a bottle in front of me than a frontal lobotomy!"

Thanks a bunch.

P.S. The printf didn't work. echo -e did.

Last edited by mph; 10-12-2007 at 10:43 AM.. Reason: update
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Piping the "script" command through the logger command.

I use the snippet below in /etc/profile on RHEL Linux to capture command line logging and it all works well and good. Now I'd like to pipe the same output from script through the logger command so it all gets logged to syslog. The only additional code I've added is in bold below (|... (4 Replies)
Discussion started by: woodson2
4 Replies

2. UNIX for Dummies Questions & Answers

Piping commands

Hi I am tryin to undertand piping command1|command2 from what i learn output of cammand 2 is an intput for command 1 right? If so . What dose next sequence do cat f1 >> f2 | grep '^' I think it takes context of f1 and Concatenate's it to f2 and then looks for ....i don't know..... (7 Replies)
Discussion started by: iliya24
7 Replies

3. Shell Programming and Scripting

Piping to a python script

Hello, I have a python script (not created by me), let's call it myscript, which I call with several parameters. If I don't provide the --password parameter, the script will ask the user to input the password. So I run the script like this: /wherever/myscript --username=whoever... (3 Replies)
Discussion started by: gplayersv
3 Replies

4. Shell Programming and Scripting

Exit code from piping in unix shell script

Hi , I have following code in my shell script : "$TS_BIN/tranfrmr" "${TS_SETTINGS}/tranfrmr_p1.stx" "${TS_LOGS}/tranfrmr_p1.err" | ( "$TS_BIN/cusparse" "${TS_SETTINGS}/cusparse_p2.stx" "${TS_LOGS}/cusparse_p2.err" | ( "$TS_BIN/tsqsort" "${TS_SETTINGS}/srtforpm_p3.stx"... (8 Replies)
Discussion started by: sonu_pal
8 Replies

5. Shell Programming and Scripting

Piping output from a command into bash script

Hi all. I am using procmail to deliver an email to a script I am developing. Procmail delivers the email to the script on standard input. I imagine this is the same as piping input from a command into the script. Hence I've been testing my script by running echo 'test' | sms-autosend-backup.sh ... (2 Replies)
Discussion started by: akindo
2 Replies

6. Shell Programming and Scripting

problem piping input to script with echo

I am trying to have a script run without interaction from the command line. So in my script i have a line like this echo -e "\n\n\ny\ny\n" | ./script the goal being the ability to mimic 3 Enter presses and 2 'y/n' responses with 'y' followed by enter. For some reason tho, it is not... (1 Reply)
Discussion started by: mcdef
1 Replies

7. Shell Programming and Scripting

KSH script: piping passes command-line arguments

Dear forum I have the following small script: #!/bin/ksh echo -e "abba-o" | awk -F '-' '{ print $2 }' | cut -b 1It needs to be ksh.. in bash I don't have this problem. If I run this on opensuse 10.2 I get this as output: e If I run this on suse enterprise 10 sp2 then I get this: o ... (1 Reply)
Discussion started by: gemtry
1 Replies

8. Shell Programming and Scripting

Piping / Executing

I've got a file with lots of commands I want to run in it. They're formatted like so: cp /path/to/file /path/to/new/file and on and on and on. Hundreds of them. Anyways, I'd like to execute them one at a time, then check what time it is, and repeat this process until 7am. I can... (3 Replies)
Discussion started by: ProFiction
3 Replies

9. Shell Programming and Scripting


I am using pipes (specifically piping out) in Perl to put an array from one file into an array in a different file. I can't figure out how to transfer the array. I kow how to open the pipe : open (FILEHANDLE, "| file") or die~ but how do I transfer the array. I think it has something to do with... (1 Reply)
Discussion started by: lnatz
1 Replies

10. UNIX for Advanced & Expert Users


i want to fully undertand redirecting/piping. i know most of the basic stuff, like ls|less or cat file|grep hello etc etc. but there are a somethings like find / -name file 2>/dev/null. what's is the 2? i know it redirects the errors (at least Permission denied ones) to /dev/null (the unix... (3 Replies)
Discussion started by: crashnburn
3 Replies
Login or Register to Ask a Question