Help with Bash Scripting
Ok, so. My friend is giving me tasks to do to learn various parts of Linux, commands, etc.
He gave me a task of making script where:
It starts as any given shell of my choice (I use the shell I work with, BASH), and turns BASH into another shell of my choice (I chose TCSH).
When run, there should be no output.
After the script finishs, it should be able to run again to turn this tcsh script, into a bash script.
So, with that all said and done, here's the script.
#!/bin/bash
# First, we create our variables (tempfile - the location and name of the scratch file, and where the convert binary is).
TMPFILE=`mktemp /tmp/convert.XXXXXX`
CONPWD='/home/shell/jason/bin/conshell'
echo "TMPFILE = `echo $TMPFILE`"
echo "CONPWD = `echo $CONPWD`"
echo "Variable Creation Successful"
# Second, we take the tempfile, and dump the alternate into it.
cat $CONPWD | sed 's/ba/ba1/g' | sed 's/tc/ba/g' | sed 's/ba1/tc/g' > $TMPFILE
echo ""
echo "sed's passed"
# Third, we remove this file.
rm $CONPWD
echo "Removed conshell."
# Fourth, we copy the temp (mirror file) as the new convert file.
mv $TMPFILE $CONPWD
echo "TMPFILE is now CONPWD"
exit
Now, I know I said no output, but I have it there as a debug.
Basically, when I run it, tons of temp files get created.
By the time I ^C'ed the script, I had about 40-50 some odd files in /tmp.
And no, I never get a 'echo' output :(.
Thanks in Advance.
Ok, quotes, not backticks, oops!
So, here's the thing I'm still trying to find out.
As I'm sure you see, I have that 'conpwd' command. I found out that if I run `pwd` from inside the script, it doesn't matter. It will only tell me where I am.
I don't want this file to move from it's current directory, but I want it to be statically defined.
I'm probably going to start fishing through configure files and such...
Maybe, is there an environment variable I don't know about?
Thanks again.
[snip]
Issue #2, those command don't work under tcsh ;_;.
I think I'm going about this rather wrongly.
Any help, at all... would be greately appreciated.
He gave me a task of making script where:
It starts as any given shell of my choice (I use the shell I work with, BASH), and turns BASH into another shell of my choice (I chose TCSH).
When run, there should be no output.
After the script finishs, it should be able to run again to turn this tcsh script, into a bash script.
So, with that all said and done, here's the script.
#!/bin/bash
# First, we create our variables (tempfile - the location and name of the scratch file, and where the convert binary is).
TMPFILE=`mktemp /tmp/convert.XXXXXX`
CONPWD='/home/shell/jason/bin/conshell'
echo "TMPFILE = `echo $TMPFILE`"
echo "CONPWD = `echo $CONPWD`"
echo "Variable Creation Successful"
# Second, we take the tempfile, and dump the alternate into it.
cat $CONPWD | sed 's/ba/ba1/g' | sed 's/tc/ba/g' | sed 's/ba1/tc/g' > $TMPFILE
echo ""
echo "sed's passed"
# Third, we remove this file.
rm $CONPWD
echo "Removed conshell."
# Fourth, we copy the temp (mirror file) as the new convert file.
mv $TMPFILE $CONPWD
echo "TMPFILE is now CONPWD"
exit
Now, I know I said no output, but I have it there as a debug.
By the time I ^C'ed the script, I had about 40-50 some odd files in /tmp.
And no, I never get a 'echo' output :(.
Thanks in Advance.
Ok, quotes, not backticks, oops!
So, here's the thing I'm still trying to find out.
As I'm sure you see, I have that 'conpwd' command. I found out that if I run `pwd` from inside the script, it doesn't matter. It will only tell me where I am.
I don't want this file to move from it's current directory, but I want it to be statically defined.
I'm probably going to start fishing through configure files and such...
Maybe, is there an environment variable I don't know about?
Thanks again.
[snip]
Issue #2, those command don't work under tcsh ;_;.
I think I'm going about this rather wrongly.
Any help, at all... would be greately appreciated.
