Computing.Net > Forums > Unix > howto add ctrl chars to bash script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

howto add ctrl chars to bash script

Reply to Message Icon

Name: Peter Marshall
Date: May 8, 2003 at 05:21:04 Pacific
OS: intell
CPU/Ram: 256
Comment:

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 work

anyway, if you have any ideas, it would be much appriciated.

thanks
Peter




Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: May 8, 2003 at 06:30:53 Pacific
Reply:

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


0

Response Number 2
Name: peter marshall
Date: May 8, 2003 at 06:51:54 Pacific
Reply:

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


0

Response Number 3
Name: LANkrypt0
Date: May 8, 2003 at 07:58:14 Pacific
Reply:

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.


0

Response Number 4
Name: nails
Date: May 8, 2003 at 08:06:32 Pacific
Reply:

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 script

Regards,

Nails


0

Response Number 5
Name: nails
Date: May 8, 2003 at 08:09:26 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: peter
Date: May 8, 2003 at 09:12:01 Pacific
Reply:

thanks :)


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: howto add ctrl chars to bash script

RE:howto add ctrl char to unix scri www.computing.net/answers/unix/rehowto-add-ctrl-char-to-unix-scri/4996.html

converting bash script to csh script www.computing.net/answers/unix/converting-bash-script-to-csh-script/3588.html

Converted BASH script acting strang www.computing.net/answers/unix/converted-bash-script-acting-strang/4385.html