Programming :: C-shell Scripting Syntax Error When Defining Two Variables A1 And A2

Apr 5, 2011

I am trying to modify a script for research purposes and am having difficulty here as I have little prior experience with C-shell scripting.

The script looks as follows (it includes tcl commands like runFEP that you can ignore)

#!/bin/bash

for ((old=1, new=2; old<=4; old++,new++))
a1=${old}%50
a2=${new}%50
do
cat > input${new}.conf <<EOF
${a1}
code....

My question: I keep getting a syntax error when defining my two variables a1 and a2. I essentially need these variables to be
a1 = value of variable old divided by 50
a2 = value of variable new divided by 50

View 1 Replies


ADVERTISEMENT

General :: Script (Case & IF Statement Syntax) - Easy To Answer If Know Shell Scripting

May 6, 2011

Im a bit stuck with a simple script that im practicing with... im trying to get my head around some simple scripting. Basically i want to write a script that will work as below: It will ask the user to enter their userid. If its correct it will say 'Correct' If its the wrong id (But the ID exists in /etc/passwd) then it will say 'incorrect' If its not a valid userid it will say 'doesnt exist'. What i have so far is:

[Code]...

# If the user enters their own userid they will get a comment saying 'correct' $LOGNAME) echo "Correct";;

# If they enter another users ID (That exists in the /etc/passwd), then they get a message to say 'incorrect userid used'. Im not sure what i need to do here to get it to check the /etc/passwd to see if the input exists in there.... im guessing some kind of simple 'if' statement to say ---- "if 'input' exists in /etc/passwd then echo "incorrect userid used"

# If its entered incorrectly and not a valid ID then they will get this comment. Again, im guessing this part would be similar to te above option..... *) echo "not a valid ID";;

Ive managed to work out how the basic Case staements work, but to add a conditional statement based on the input, i just cant figure out. I have tried looking on google, and found some help but it doesnt really explain how i check the input against the /etc/passwd.

View 17 Replies View Related

Programming :: Shell Scripting Loop Error Yal2361: Command Not Found?

Jul 22, 2011

I have written the following script in my linux server to add users for LDAP database.But i can't able to run this.

The script is as following

#!/bin/bash
echo "Mention the username which you want to convert LDIF format"
read username
if ["$username" -e "/ldiffile/passwd"]; then
echo "Username already exists"
else
cat /etc/passwd | grep -i "$username" >> /ldiffile/passwd
fi
The output which i got :
. ldapadd.sh
Mention the username which you want to convert LDIF format
yal2361
-bash: [yal2361: command not found

please let me know where need to change and what

View 5 Replies View Related

Programming :: Run Small Shell Script - Bash - Syntax Error Near Unexpected Token `('

Jul 9, 2010

I was trying to run small shell script, but could not run. I got the error like in subject.

This is exact way i was trying to do.

View 6 Replies View Related

Programming :: Shell Scripting / Create A Shell Script Similar To Ls?

Jun 5, 2011

I am trying to create a shell script similar to ls, but which only lists directories. I have the first half working (no argument version), but trying to make it accept an argument, I am failing. My logic is sound I think, but I'm missing something on the syntax.

Code:
if [ $# -eq 0 ] ; then
d=`pwd`
for i in * ; do
if test -d $d/$i ; then
echo "$i:"
code....

View 10 Replies View Related

Ubuntu :: Defining Variables With Printf?

Mar 24, 2010

I am trying to use bash 'printf' to format an environment variable.Doing this I get on the screen just the format I need (underscores mean blank spaces):prompt> printf "%10s" "1.23"________1.23Unfortunately, when this is assigned to a variable, the format disappears:prompt> X=`printf "%10s" "1.23"`prompt> echo $X1.23Does anyone know what can be done in this case to get a proper format?Why does not 'printf' respect the left blank spaces when assigning values to a variable?

View 3 Replies View Related

Slackware :: Standard Location For Defining Environment Variables

Jan 4, 2011

I'm setting up Tomcat right now, and I've been directed to create a tomcat_home (catalina_home as of writing) environment variable.

Where is the default location for env variables in Slackware? My current inclination is to create a new script /etc/profile.d/tomcat.sh.

View 1 Replies View Related

Programming :: Setting Variables In C-shell?

Jul 12, 2010

I'm running into a problem when I try to set a variable to an awk output in c-shell. Right now my command is Code: set STR_MSG_TYPE = `awk -F{ '/msg_type/ {print $2}' <filename> | tr -d }'/''*' ` I then run echo to see what the output is and it returns blank, however, when I run the same awk command from the command line, I get an actual output of "MT-715". Am I setting my variable incorrectly? I do something similar using the date command to set a STR_DATE variable earlier in the code and it works fine and I use the same syntax.

View 1 Replies View Related

Programming :: Shell - Substition Of Variables?

Mar 22, 2011

i have following code :

Code:
TMPDIR=`mktemp -d`
mkdir $TMPDIR/old/

[code]...

View 3 Replies View Related

Programming :: Shell Scripting Array - Bad Substitution

Jun 19, 2009

I made a little rsync script for log transfer.

Code:
SERVERS=(SERVER1 SERVER2 SERVER3)
SERVER1_SERV=(web ftp mail)
SERVER2_SERV=(web transcoding)
SERVER3_SERV=(web ftp mail)
for SERVER in ${SERVERS[@]}
do
echo "Starting tranfer for server $SERVER"
for SERVICE in ${$SERVER_$SERVICE[@]}
do
something_to_be_done
fi
done
But when I run it I get ${$SERVER_$SERVICE[@]}: bad substitution

View 5 Replies View Related

Programming :: Shell Scripting: How To Create A User

Sep 5, 2010

How do I create a user account in a shell script? I know this may sound n00bish to you, but I know it's more than just mkdir-ing the home directory and subdirectories.

View 7 Replies View Related

Programming :: Advanced Uses Of Variables In Korn Shell?

Jul 28, 2011

Somehow I'm not really managing this thing, which would d be a nice way to useariables.What I am doing is setting up compound variable in ksh. What I have is a "config" file, which has fields delimited by a semicolon

Code:
cat ${CONFIGFILE} | grep -v "^#" | grep -v "^$" | while read line
do

[code]...

View 14 Replies View Related

Programming :: Convert String Into An Integre In Shell Scripting?

Dec 2, 2010

I need to part a string into separate integers ....like "0x0-0xffffffff,0x20000" into 3 integers 0x0 and 0xfffffff and 0x20000.... i can't use any other high-level languages ..

View 3 Replies View Related

Programming :: CGI Shell Scripting : Possible To Call Function From Other Script?

Mar 15, 2011

I got two cgi shell scripting files. Is it possible when i am in file 1, to call a function from file 2?

View 2 Replies View Related

Programming :: Compare Two Files Using Perl Or Shell Scripting?

Mar 8, 2010

I want to compare the following two tab-delimited .txt files (both were subsets of the original files) by comparing Columns 3 and 4 simultaneously. It is easy to compare C3 because both C3s are just numbers. But how to compare C4s?Basically, in File1, "G,G" = G in File2, "C,C" = C in File2, "A,A" = A in File2, "T,T"= T in File2.In File2, A/T in Column4 just equals "A,T" or "T,A" in Column4 of File1. C/T in Column4 just equals "C,T" or "T,C" in Column4 of File1, and etc.

File1:

C1C2 C3C4
ih509rs12345467244750"G,G"
ih499rs6049687244911"C,C"
ih508- 7244977"A,A"

[code]....

View 2 Replies View Related

Programming :: Ignore Case In If Statement Shell Scripting

Feb 3, 2010

How do i make my strings case-insensitive while comparing them with an if statement?

View 2 Replies View Related

Programming :: QNX Checksum Call In Cgi Shell Scripting Not Working?

Mar 11, 2011

I have a QNX machine with a slinger webserver running on it. With a cgi script i'm trying to do the QNX cksum call and compare it's output value with a fixed output. When i execute the script at the command line it works perfect, but when execute this script by by the webserver in my browser it doesn't work. Here's my code:

#!/bin/sh
FILE="/home/checkfile"
ORIGCHECK="1712885500"

[code].....

Could it be possible that i'm not allowed to do the cksum call in combination with the slinger webserver?

View 4 Replies View Related

Programming :: Shell Scripting: Scraping Public IP And Emailing?

Jul 3, 2011

so I wrote a simple script to scrape whatsmyip.org for my public IP address and then email it to me if it has changed. I set this up as a cron job ever 30mins.the problem is, it works for about 18 hours and then will have an issue where it says "line 33: [: too many arguments" Which line 33 happens to be my if statement. Now like I said it works fine for about 18 hours, i run the script with 2>&1 to a .out file so i can see what its doing...this is the output of the .out file, the "xxx" does actually show the ip.."PHP Code:

xxx.xxx.xxx.xxx
already in file
xxx.xxx.xxx.xxx

[code]....

View 14 Replies View Related

Programming :: Exporting Makefile Variables To $(shell) Environment?

May 12, 2010

I'm aware that one can export make variables to other makefiles; however, how does one export them to the environment of $(shell)? Take the example below:

Code:
export TEST
VARIABLE=$(shell echo $$TEST)
.PHONY: all
all:
#$(VARIABLE)

In this example, I might call make TEST=test. The goal is for $TEST to be available to the environment of the shell escape. This is because I need its value in a script which is called. For example:

Code:
VARIABLE=$(shell i-need-TEST.sh)My current solution is the following:VARIABLE=$(shell export TEST="$(TEST)"; i-need-TEST.sh) but this only works if I know all if the variables needed at that point (as opposed to being able to export variables in included makefiles.) Is there an easy solution?

View 4 Replies View Related

Programming :: Indexing Variables In Lists Using Shell Scripts?

May 27, 2010

I have a question concerning indexing over lists with unix shell scripts. I have very large text files (up to 20 Gb) with the data shown below:

80011412865610
43000216943210
4710510513101

[code]...

View 14 Replies View Related

Programming :: NSH Shell Scripting \ The Value For The Vatriable Would Be Coming From A File With Three Columns?

Jun 24, 2011

I'm writing a script and I have doubts on how to assign values to an already established variable. The value for the vatriable would be coming from a file with three columns. I'm using the awk command for this. Am I doing it correctly? which of the following two ways is the better one or if both are wrong which one should I use?

#!/bin/nsh
inputfile=$1
rolename=$2

[code]....

View 2 Replies View Related

Programming :: Shell Scripting For Accepting Input From Different Directories Automatically

Nov 6, 2010

The two shell scripts (t1prog and t2prog) are given below they are working fine. The input for the first program is 't1.det' and for second program is 't1.rnaml'. These two input files are in 'dir1' folder. I am executing the shell like 'sh t1prog > t1out' and 'sh t2prog > t2out' from this directory only. Then I am executing a java program 'java RNA'; for this, t1out and t2out are input files used in the program and I am getting the final output on screen.

The input files 't1.det' and 't1.rnaml' are in different folders with same name and with different values. Each folder specifies one gene sequence input files.

In mfold directory there are 5 directors and each directory contains these input files as shown below
cd mfold
dir1 dir2 dir3 dir4 dir5
cd dir1
t1.det t1.rnaml

[Code].....

for inputs in different directories and executing these and redirecting the final ouput after executing 'java RNA' statement to a file is needed.

View 2 Replies View Related

Programming :: Shell Scripting - Value Disappears Depending On Argument Order

Mar 21, 2011

Examples:
Code:
$ ./test.sh -a -c 2
operator is -gt
remcount is
^ value missing!

Code:
$ ./test.sh -b -c 2
operator is -lt
remcount is
^ value missing!

Yet when "-c" is the first argument, its value is present:
Code:
$ ./test.sh -c 2 -b
operator is -lt
remcount is 2
What could I do to ensure the value of "-c" is picked up regardless of the argument order?

View 5 Replies View Related

General :: Syntax Error In Shell Script While Using If Condition?

May 28, 2011

I am writing a simple shell script where it checks the condition using if condition.

Code:
if [ $name == "JOHN" ] then admin='YES'; fi
if I use like this I am getting below error

[code]....

View 1 Replies View Related

Programming :: Shell Scripting: Trying To Combine Upload And Download Totals From Txt File By Ip Add

Sep 6, 2010

I have two files, uploads.txt and downloads.txt. I would like to combine the columns of these files based on the ip address. How can I best do this?

Uploads.txt Code: 192.168.0.147 1565369
192.168.0.13 1664855
192.168.0.6 1332868 Downloads.txt Code: 192.168.0.147 9838820

[code]...

View 7 Replies View Related

Fedora :: Shell Scripting / Bash Error Est.sh: Line 9: Kill: (20831) - No?

Jun 11, 2010

I was giving the found the following shell script. I was told it was suppose to ensure only that only one script of Test.sh can run..

However, I get it looks like it has a error when i run it... As i get Test.sh: line 9: kill: (20831) - No such process

what is going on in this script can someone explain it to me... I thought it suppose to work like a singleton for my script creating a file .run-test-sdolan. However, i don't see how or where .run-test-sdolan is create?

sdolan@staging:$ vi Test.sh
#!/bin/sh
MYDIR=`dirname $0`
CONFDIR=$HOME/
code....

View 4 Replies View Related

Server :: Shell Scripting Command Line / Getting Error While Passing Parameter?

May 6, 2011

I am very new to shell scripting.How does one pass a command-line parameter to a shell script?for the below program
#/bin/bash
mount -t cifs -o user=ramkannan,password=Linux123@ //10.200.1.125/ramkannan /MT
cd /MT/test
date=`/bin/date "+\%Y-\%m-\%d-\%H-\%M-\%S"`
mysqldump -uroot -pram2@ employeedb > $date.sql
gzip $date.sql

I want to pass parameter for everything,i tried in google and did but iam getting error while passing parameter to all

#/bin/bash
mount -t cifs -o user=$1,password=$2 //10.200.1.125/ramkannan /MT
cd /MT/test
date=`/bin/date "+\%Y-\%m-\%d-\%H-\%M-\%S"`
mysqldump -uroot -pram2@ employeedb > $date.sql
gzip $date.sql

i was getting error while passing parameter to all.

View 2 Replies View Related

Programming :: Finding Maximum Length File In A Directory Recursively Using Shell Scripting?

Nov 8, 2010

I want to find maximum length file in a given directory. It should search recursivley. I want this to be done using ls and simple looping constructs.

View 6 Replies View Related

Ubuntu :: Korn Shell: Syntax Error On Test A Function With Parameters?

Jan 4, 2011

Some may recall I recently gave up on bash, rather than give up my programming style.Surely I will have reason to return but that's another story. My little issue now:I am debugging a new [Korn] shell script. I have a function that performs a specialized match on a string and I see that I am able to call that function with no problem, with both of it parameters. The function does not do any print or echo command - it uses "return" for a TRUE (0) of FALSE (1), as is the shell exit code convention. Thus, I have the following test:

Code:
if [[ match_except_release ${PATH_DIR[$LC]} bin ]]
then

[code]....

View 2 Replies View Related

Programming :: Parse Error: Syntax Error, Unexpected '@' In Php Code

Jun 14, 2011

Parse error: syntax error, unexpected '@' in C:xampphtdocsminippromail.php on line 8 .......its not recognizing the '@' symbol. heres the code im working with

<?php $receiver = myfriend@ourmail.co.in; $subject = wish; $content = Hi! My dear friend how are you.; $sender = myself@ ourmail.co.in ; $headers = From: $sender; mail($receiver,$subject, $content,$headers); echo Mail has been sent successfully.; ?>

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved