I have a set of commands that I am using to copy specific areas of source code in a Cold Fusion document and export the code into recreations of the original files into a sub-directory. Here are the 3 commands I am using:
The first command is making the sub-directory. It is also printing the area of code I want that is in between the two comment tags and exporting it into the same file name that the extraction was done, only into that sub-directory.
The second command is doing the exact same thing as the first command (minus the make directory command), except this one is aimed for a second comment phrase.
The third command is to delete unnecessary comment strings that would appear after using the first two commands.
I am very illiterate when it comes to this type of stuff. How I have gotten this far is by help of a co-worker. I understand the commands listed above, but that is basically all I know (exceptions are basic commands like pwd, ls, echo, etc.). I am using Cygwin on Windows XP Pro.
Now to the point of things. I want to be able to put these commands in a shell script so I do not have to keep typing them in every for every single web directory that I will use these commands on. Is there any simple way to do this? And can I use Notepad++ to create/edit the shell script?
Just for you, I've downloaded and installed Cygwin!
I've been using it for about three minutes, and it's driving me up the wall already!
Copy your code into an editor (preferably not notepad!) and save it somewhere. If you use the script often, then /usr/bin, why not?
(let's assume notepad!)
Paste your code, save and exit.
Now, Notepad, being clever, will call your file cfCopy.txt, so...
Now you can "cd" to anywhere and run cfCopy.
If you chose to put the script somewhere else, not in your path (like /usr/bin), edit your bash profile:
and at the end, add the line:
"vi .bash_profile" doesn't work, as it seems cygwin doesn't come with vi (maybe it does, but I didn't have a good look yet). I would download WinVi and put it in /usr/bin! Like I just did. Then you'll never have to use notepad again.
After installing cygwin I wrote a "hello world" equivalent script to test it:
Which gave this error.
Then I fiddled with it adding blank lines at the end, etc.
But I eventually got it working (I've had colds that came and went quicker) by using WinVi (again with some fiddling).
I can't believe I'm the first person to write a script in Cygwin (I most certainly am not).
But I can say that what I wrote does work! I got it to work by "fiddling".....
Can anyone here from the Cygwin community - if there is such a thing - recommend something, anything, that means we can write a basic script without having to muck around for ages pampering to every of Windows' short-comings in relation to saving a basic text file to disk?!
From the scripting perspective, there's not a problem. For me the problem is from the Windows (DOS) side. We must be doing something wrong.
Just "fiddle" until a Cygwin guru turns up...
---------
I've just played around some more, and it seems that (in notepad) adding a blank line at the very end makes it work.
I will have to Wikipedia the origins of CRLF. For the life of me I can't see why both are neccessary. UNIX didn't have both for 40 years, and noone died!
Hi Folks -
Is there a way to add two execs to one script? For instance, I need to redirect the stdout and stderr to two separate directories. I want to do this:
#::-- Direct STDOUT and STDERROR to repositories --::#
exec 2>"${_ERRORFILE}" > "${_LOGFILE}"
exec 2>"/new/path/file.err" >... (7 Replies)
Hello All,
I have written a script which which is working fine to a certain logic of it. But i want a part of the script to run two commands at 00:10 hrs every day. These two command are
1. rm -rf /path/to/folder
2. mail the content of a file.
How do i achieve this. Thanks.
... (4 Replies)
Hi
script> isumid 98765432
if i give above command in cmd prompt it is running the same thing if i give inside the shell script it is not working
below is the code
#!/bin/bash
isumid 98765432
please give me a solution (16 Replies)
I am trying to learn to write basic shell scripts. I have a little experience with perl but none with shell. I am trying to write a simple script to write the last 15 or so lines of log files for my web server to a temp file so I can view all at once. Here's what I have. Are you not able to use... (6 Replies)
Hi all,
I am trying to use the Ex editor and its commands in a script - more specifically within an if statement within a while loop.
Here are the basics of the loop:
cat $file1 | while read line
do
grep $line $file2
if ]
then
echo $line > $file2
elseex $file2
/ESI185... (4 Replies)
I am using Fedora 8,Red hat 9.
Whenever we write a new command. Then we goto "/usr/bin" and then place this in this directory.And hence we can use it as a command anywhere from the terminal.
We generally see commands like "trap" which run only in bash shell.We also have other shell specific... (1 Reply)
Hi friends this is first post i am very new to shell scripting so i require your expertise to do the following thank u
I need to write a shell script which will run the following commands
pg_dump bank > backup(Enter)
Wait for bash prompt to appear coz it indicates that the command is... (23 Replies)
Hi ,
I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell.
So scenario is that
- I need to have one shell script which is ran as a part of crontab
- in this shell script I need to do a... (2 Replies)