I am new to Linux and have just started performing Gaussian calculations for a new department created at my work.
I am interested in creating some small scripts to complete some of the routine tasks.
I have created a file based on an old BASH file but it is having issues.
#!/bin/csh
name=$(1%.*)
formchk "%1" "%name.fchk"
This is a test script to test if I could script and it failed misserably.
I am trying to take a file "filename.chk" and run a formchk function that would create a new file "filename.fchk"
formchk is a function of gaussian that required a *.chk input and a named output file. i am trying to make this file univeral for all filenames that would be submitted to it. If this works I will add additional maniputation as needed.
I ran "chmod +x" on the script and executed with "./"
The error i received was "invaid varialbles"
any assistance would be greatly appreciated.
Thanks!!!
Hi, is there a reason you are using csh? Most people on this forum -me included- would suggest you save yourself a headache and switch to a bourne shell derivative, like sh, ksh, bash.. http://www.faqs.org/faqs/unix-faq/shell/csh-whynot
P.S. I re-read your OP and saw you based this on a bash script. I would suggest you continue to use bash as syntax will most likely be different with csh anyway so if you are following a bash example
I would expect you'll have fewer porting issues sticking with bash.
Thanks for the info, I will read up on csh.
I do not have BASH on this machine, or have not located it.
I am very new to scripting (this is my first script), i understand that syntax will be differrence the difference shells, does anyone have a suggestion on how to complete the task mentioned on the first post?
If bourne is on all machines then I am definately okay with using bourne, but I don't know where to start.
Thanks again.
I think you are looking to run a script by passing it a filename.chk file, which is then passed to a program that creates a filename.fchk file?
#!/bin/ksh
# $1 is the first argument passed in. Expected to be a .chk file. The string operations
# used here strip off the period and the extension.
filename=${1%.*}
# Double quotes preserve spaces in case filename has spaces.
# Remove "print" below when ready to run. With "print", it will show you the command line that will be run.
print formchk "${1}" "${filename}.fchk"
exit 0
This is drastically lacking in error checking, but maybe it will get you started.
Any even slightly UNIX system ought to have a bourne shell somewhere, often /bin/sh. By comparison, very few have csh these days. Nothing stops someone from installing one later of course.
This ought to work in any basic-functionality bourne shell. It will obliterate your $1 $2 ... variables though, which is why we save VAR for later.
VAR="$1"
IFS="."
set -- $VAR
formchk "$VAR" "${1}.fchk"