Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
sadly i had tried the eval command , i typed eval ls, in my xterm and now all i get is the result of eval ls no matter what i type !!
do u know how to disable this command ?
I had been trying to get the answer by myself, so i tried
eval ls
to try to get the execution of ls
but then when i read the answer HOMEY posted, i tried it out, i copied it into a script called execute_ls
but everytime i type on the xterm :
chmod +x execute_ls
then
./execute_ls
all i get is
execute_ls execute_ls~
and when i typed set -x to trace whats happening
i had a line +echo <listoffilesinthedirectory>
its driving me nuts
i cant do anythg !
Last edited by mayaabboud; 01-06-2008 at 09:44 AM.
then i go and write chmod +x execute_ls
then ./execute_ls
which gives me :
execute_ls execute_ls~
this doesnt work, i tried reopening a new terminal many times. i even restarted the computer !!
the only thg that works is when i add an echo line at the beginning like this:
echo "write>>"
read Y
echo "write>"
read Z
if [[ "Y" = "$(ls)" && "Z"="$Y"]] ; then
echo $Y
echo $Z
fi
this works, meaning that the script responds, by telling me to "write>>"
but it gives me no answer
dont blame me for being complicazed, everytime i call a script i get the result of an ls command !!
then i go and write chmod +x execute_ls
then ./execute_ls
which gives me :
execute_ls execute_ls~
Maybe I'm not following, but this looks to me the correct behavior. Let me dissect your simple script:
1. #!/bin/bash
this is the so-called sha-bang: it tells to use /bin/bash as interpreter
2. Y=$(ls)
this assigns to Y the output of the command ls. This is called "command substitution" and the syntax $(command) is equivalent to `command` (with back-ticks).
3. Z=$Y
this assigns to Z the value of Y, which is still the output of the ls command
4. echo $Z
this prints to the standard output the value of Z, that is the output of ls: execute_ls execute_ls~. It looks like in the current directory you have only the script "execute_ls" and its backup file "execute_ls~" (that one created by text editors like gedit).
What am I missing here? Can you re-formulate your original question?
That's showing the scriptname and the backup scriptname file which is what it's supposed to do.
Maybe you wanted a more verbose listing as from ( ls -al )
Code:
#!/bin/bash
y=$(ls -al)
z=$y
echo $z
Just a side note, I use script name which are less likely to get you into trouble executing something unwanted. For example: my_script
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.