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


ADVERTISEMENT

Software :: Scripting Error - Export Command Not Found?

Apr 1, 2010

I am attempting to create a script for Grid job submissions. I have most of it completed but when testing I've run into some problems.

How it works is that I have 2 wrapper files, one is the top of the script, the other the bottom, the original script imports commands for the middle.

Basically this is what is to happen:
cat script-start.sh >> workerscript.sh
echo commands >> workerscript.sh
cat script-end.sh >> workerscript.sh

workerscript.sh gets created with no problems but when it is run I get:
export: command not found

I think that the new script is not calling bash which gives the problem. I don't know how to fix the problem though because I have the shell set in the script-start.sh.

#!/bin/sh - tried /bin/bash, same result
export PROJECT=/......
export PROJSOURCE=/......

View 14 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 :: 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 View Related

Programming :: Bash Shell Scripting / Using The Sort Command To Sort The Top 5 CPU Processes?

Feb 28, 2010

What options should I use when I'm using the sort command to sort the top 5 CPU processes (ps -eo user,pid,ppid,%cpu,%mem,fname | sort ??? | head -5) showing max to min usage?

View 2 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

Programming :: Global Bash Shell Functions - A.sh: Line 2: Echotm: Command Not Found

Sep 13, 2010

I wonder if there is anyway to make a user-defined bash shell function global, meaning the function can be use in any bash shell scripts, interactively or not. This is what I attempted:

Code:

$ tail -n 3 /etc/bashrc
echotm () {
echo "[`date`] $@"
}

[code]....

View 11 Replies View Related

Ubuntu :: Shell Scripting Command Doubt?

Jan 1, 2011

How do i find out if a particular item is a file or a folder through the terminal ls -la gives 'd' before the permissions for every folder and '-' before every fileLike i want to write a script that backup data if it is a folder and deletes if it is a file

View 2 Replies View Related

Server :: Dos2unix Command In Shell Scripting?

Jul 5, 2011

I am new to shell scripting..I really need ur help or guidance here..I have a text file where i have to use dos2unix command.

Now the problem is how do i pass dos2unix command in the shell scripting after it had read the text file ??
And give out the new text file.

View 3 Replies View Related

General :: Shell Scripting: Parse Parameters From Command Line?

Mar 12, 2010

myscript [-a a-arg] [-c c-arg] [-b] [-e] somedirectory

Given that I want my shell script be invoked at the command line using the above parameters - where [these brackets] denote that they are optional - what is the best method to parse them?

View 1 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

General :: Shell Programming Using While Loop

Jun 28, 2010

I am trying to do some shell programs. I tried some sites regarding the while loop, they give the structure as:
Code:
while [ n1 -lt 500 ]
do
echo $((n1+100))
done

But the below code also worked for me:
Code:
while ((n1 > 500))
do
echo $((n1+100))
done
By using (( )) I could use while, for. But the documentations didnt follow this way. I mainly use this for datastructure programming.

View 4 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 :: 32512 Error Code In Perl When Trying To Run Shell Command?

Nov 29, 2010

when I execute the command from the shell command line - it works and no error code.if I do the exact same command from a perl file - it fails with code 32512.the file is created from the same perl script that runs the command that fails. file permission is 0664.

Code:
#! /usr/local/pkg/perl-5.8.8/bin/perl
print "Content-type: text/html

[code]...

View 3 Replies View Related

Programming :: Unable To Execute FOR Loop In Shell?

Apr 19, 2011

hint me why and how to execute the below for loop, the way i am trying to?

[bkcreddy17@local:~]$ cat -n test
1 date
2 ls -l

[code]...

View 14 Replies View Related

Programming :: Custom ZSH Error Prompts / Zsh: Command Not Found?

Mar 25, 2011

Using zstyle, I can create a custom warning for messages and such, but looking into the man pages and all, I do not see anything for customizing actual error messages in ZSH, as such:

Code:
casper@ltp01[/home/casper][19:14] - asdfsdafasdfjsdf
zsh: command not found: asdfsdafasdfjsdf

View 3 Replies View Related

Programming :: Error: ./10aa: Line 5: [-n: Command Not Found 127

May 25, 2011

Quote:

Explain the error?

View 2 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

Programming :: Calling Vars In A For Loop In A Shell Script?

Oct 8, 2010

# variable declaration
stt=10
enn=20
stp=1

# I want to do it in the following structure but not sure how to call # the stt, enn and stp in a for loop

for (( i = $stt; i -le $enn; i=i + $stp ))
do
blah blah
done

View 9 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

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







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