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.
Distribution: Mostly RedHat. Also Suse, Ubuntu, PHLAK etc.
Posts: 149
Rep:
>> help
I don't know if this is a real programming issue...
I'm trying to write a script that will cd to a specific directory, then perform an ls -lahS >> logsizes.txt. Then cd to another specific directory and again ls -lahS >> logsizes.txt.
I tried it likke this:
cd /data/specific_directory1/logs/
ls -lahS >> /logchecks/logsizes.txt
cd /data/specific_directory2/logs/
ls -lahS >> /logchecks/logsizes.txt
It's not working though... It keeps saying "cd: /data/specific_directory1/logs/, no such file or directory"
Distribution: Mostly RedHat. Also Suse, Ubuntu, PHLAK etc.
Posts: 149
Original Poster
Rep:
The diretories doesn't exist actually (I'm feeling pretty stupid right now!)...
There's still a problem though, and that's that the first directory does exist, with a mountain of data in there, yet this doesn't reflect in the txt file...?
There's still a problem though, and that's that the first directory does exist, with a mountain of data in there, yet this doesn't reflect in the txt file...?
Do you mean the files are not listed in the txt file? Then the user executing your script probably doesn't have read permission on the directory.
<off-topic>
What is "The most beautiful city in the world"?
</off-topic>
Distribution: Mostly RedHat. Also Suse, Ubuntu, PHLAK etc.
Posts: 149
Original Poster
Rep:
<off-topic>
Hko, that's a bit of a sensitive topic. I don't want to reveal where it is since I don't want to step on someone else's toes if it turns out it's not the same city as the one they reside in...
</off-topic>
But back to the problem: The user seems to have all the necessary rights (sudo).
Do you think I should add sudo before all the commands?
Do you think I should add sudo before all the commands?
If your script needs the rights you granted by /etc/sudoers to access that directory, then yes, I'm sure you need to add "sudo" before the command that runs the 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.