Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am trying to put ctrl-d in my bash script. (need to execute a command that needs ctrl-d to end the command). Does anywone know how to put it in the script ?
I tried doing the following
echo -e "\005" ;did not work
^D ;did not work
^d ;did not work
echo ^d ;did not work
echo "^D" ;did not work
echo `^D` ;did not workanyway, if you have any ideas, it would be much appriciated.
thanks
Peter

Peter:
In vi/vim, to embed any special character press control-v and then control-d or whatever. Please realize you probably won't be able to cut-and-paste this.
Regards,
Nails

thank you very much for your reply. I actually tried what you are saying after I posted the message, but it still is not working right :(
this is what I have:
___________________________________________
#!/bin/sh (I have also tries using bash)
mail e48f4@unb.ca
(embeded CR)
echo Subject: Fill out time sheet
(embeded CR)
echo Dont forget to fill out
(embeded CR)
(embeded ctrl D)--------------
It works if I type line by line at the prompt, but I can't get it to work in the script. I dont get an error, but it does nnot finisth, and I have to control C to exit.
thanks again for your input.
Peter

If you have access to use joe (editor) this becomes easy to do.
try typing joe at your command line see if it opens up.
If so, all you need to do to use ctrl chars is use ` then the letter you want so you would type `d and that should do it.

Peter:
Instead of using control-d like you are, why not use a unix/linux "here document:
# untest for mail
# mailx command is one line up to MSG
mailx -s "Fill out time sheet" e48f4@unb.ca MSG
Dont forget to fill out
MSG
# end test scriptRegards,
Nails

Peter:
mailx -s "Fill out time sheet" e48f4@unb.ca MSG
Sorry, but the line above needs two less than signs between unb.ca and MSG. This forum has a problem displaying less than signs.
Nails

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |