473,387 Members | 1,897 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Bash Shell Error

Hello Everyone,

Please go through this script code .
this script files executing in bash 2.05 version without mentioning sh. That means if I type simple in command prompt :
$moverds.sh
then it is execution without any problem and when I try to execute by type in command prompt like:
$sh moverds.sh then
its giving the following Error

root@aramco2.temp.com # sh moverds.sh
+ read Line
+ ls /test
moverds.sh: bad substitution
root@aramco2.temp.com #

CODE:
#!/bin/sh
set -x
ls /test | while read Line
do
rds=${Line%_*}
ls | find $rds
if [ $? -eq 0 -a -d $rds ] ; then
if cp /test/$Line /$rds
then
echo "file:$Line : has been transfered to :$rds folder...."
else
echo "file:$Line : has not been transfered to :$rds folder...."
fi
else
if [ -f $rds ] ; then
rm $rds
fi
mkdir $rds
if cp /test/$Line /$rds
then
echo "file:$Line : has been transfered to :$rds folder...."
else
echo "file:$Line : has not been transfered to :$rds folder...."
fi
fi
done

Thank's & Regard's
Lokiii
Jul 26 '07 #1
0 1490

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: John Bowling | last post by:
I have a java (2.0) program with the following lines: String cmdArray1 = {"lp", "-d", "hp4m", "MyFile"}; System.out.println(Runtime.getRuntime().exec(cmdArray1)); It compliles properly, but...
3
by: William Park | last post by:
I'm very excited to announce shell interface to GTK+2 (2.6.1) for Bash. It read XML syntax describing the widget layout, and returns user selection as shell variable or runs shell command as...
11
by: Magnus Jonneryd | last post by:
Hi, I'm planning on writing a program that interactively is fed input via a shell (bash). I also want to be able to write a shell script that executes various commands related to my program. In...
7
by: chakkaradeepcc | last post by:
HI all, How to execute bash scripts from python (other than using os.popen) and get the values that those bash scripts return. I would be happy if someone could help me out in this.. thanks...
16
by: John Salerno | last post by:
Hi all. I just installed Ubuntu and I'm learning how to use the bash shell. Aside from the normal commands you can use, I was wondering if it's possible to use Python from the terminal instead of...
14
keyvanrahmadi
by: keyvanrahmadi | last post by:
Sorry if this post is rather long but hopefully you wont get bored half way through. I have a project in hand which i have started and have a deadline of 1 week. Basically what i need to do is to...
0
by: kukluxklan | last post by:
hi all, im tring to implement a bash shell with some operations like(pipe,redirection etc).im using execvp system call to achieve this.im stuck at redirecting the outut of a command to a file.the...
10
by: Isaac Gouy | last post by:
$ ./test_fail 1 Floating point exception - but this leaves 'somefile' zero size $ ./test_fail 1>somefile Floating point exception
1
by: Fredrik Lundh | last post by:
John Lawrence wrote: doesn't exactly work for Python scripts, though: $ cat env.py #!/usr/bin/env python import os os.environ = "hello"
6
by: Frantisek Malina | last post by:
What is the best way to do the regular bash commands in native python? - create directory - create file - make a symlink - copy a file to another directory - move a file - set permissions ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.