ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
HI !
I am desperate.
I got a little bash script.
On my PC it runs ok, I testet it in bash and tcsh shells.
The problem is that when I run it on other,remote shells;
Here are some first lines from it.
Code:
usage()
{
echo -e "usage";
echo -e "$0 proj_name cr_number"
echo -e "proj_name -- ex pcr6.1s"
echo -e "cr_nuber -- ex Q666111-02";
}
if [ $# -ne 2 ] ; then
usage;
exit;
fi
if [ ! -e ~/tmp/ ] ; then
mkdir ~/tmp/;
fi
if [ ! -e ~/tmp/puishor ] ; then
touch ~/tmp/puishor;
fi
if [ ! -e ~/tmp/log ] ; then
touch ~/tmp/log;
fi
date | awk 'END {print $1,$2,$3,$4}' > ~/tmp/puishor;
start_log=`cat ~/tmp/puishor`
start_log2=" $USER -- $start_log -- START ";
echo $start_log2 >> ~/tmp/log;
When I execute it on remote shell ( on far far far away linux Box ) without any argument it gives me
Quote:
-e usage
-e puishor.sh proj_name cr_number
-e proj_name -- ex pcr6.1s
-e cr_nuber -- ex Q666111-02
So in this case it runs ok.
But if I provide him 2 arguments, as it expected
and run
Code:
sh puishor.sh pcr6.1 Q01171801-07
it on remote shells ( in both, bash and tcsh ) says that
Code:
puishor.sh: test: argument expected
But in my shell that runs ok!!!!
Could someone help me please... at least clue me what is problem in ?
I log through telnet ( I got an user ID and password ).
I copy on that machine my script ( through ftp GUI client, using the same user ID and password)
And there I execute it, using sh command.
Is that you asked me ?
I still got one question.
What is the difference between how do I run my script by "sh myscr"" or by "./myscr" ( with "chmod +x myscr" before that ) ?
Isn't the result the same ?
This way the shell will be executed 'inside' the working shell (which means if you export an environment variable, after the execution of the script it will be preserved).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.