Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm trying to create a directory in a shell script:
mkdir -p DirName
but I always get the same error:
cannot create directory `/DirName': Permission denied
If I run the same command directly from the shell instead of using the scripts, that works perfectly.
any idea?
Thank you! :)
If you're going to use the -p option, you need to specify the full path
mkdir -p /some/path/here/DirName
I suggest listing the full path (If you plan on your shell script to change locations).
If your shell script isn't going to change locations (you're not going to move it somewhere else later), I'd use:
mkdir ./DirName
These should all behave similarly to you creating the directory in the shell.
You are trying to create a directory in the root of the filesystem (/DirName) instead of in the current directory (Dirname or ./Dirname). You don't have access to write to the root.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am very new to scripting, can anybody tell how can I switch to directory in bash.
I have tried to do like this
-bash-4.2$ cd /c
and cd c but nothing works!
Check if you have any directories in your current path!
You can check that by ls -lrt which lists the files and directories in your current path.
If there are no directories, create one using mkdir c and then do cd c
Also you can navigate to your previous directory by using cd - and your home directory by doing a cd ~
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
If the ls command lists the contents of a directory, then some output to ls <directory would seem to indicate that a directory exists.
For example, this is what I get:
> ls ~/.ssh
id_rsa id_rsa.pub known_hosts
But why then, when I type cd ~/.ssh do I get
> cd ~/.ssh
The system cannot find the path specified.
?
Why can I list the contents of this directory but not navigate to it?
I am using Windows 8
This answer is under the assumption that you are using the command prompt to execute these commands.
The reason that you can ls the directory but not cd to it, is because the ls command comes from a library that you downloaded that makes ls work on windows.
In contrast, your cd command is being executed from Windows, not from the library you downloaded.
In short, ls knows how to parse the tilde (~) as home, but windows doesn't know how to parse ~. try it: cd ~. it won't work.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Imagine this is my folder structure
filepath\targetpath
filepath\folder1
I can create the symlink when I am inside the targetpath folder
ln -s ..\folder1 folder2
but when I try to create symlink from upper level with below command
ln -s filepath\folder1 filepath\targetpath\folder2
it create shortcut file rather than a symlink to filepath.
How can I create symlink when I am outside of the targetpath folder?
If a symbolic link is not an absolute pathname (begins with /) it is interpreted relative to the directory containing the link, not your cwd when you make the link. So if you do:
ln -s filepath/folder1 filepath/targetpath/folder2
the target of the link is filepath/targetpath/filepath/folder1. You should make the symlink the same way as you did the first time:
ln -s ../folder1 filepath/targetpath/folder2
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Here are the steps I am doing again and again, and I was wondering if I can write a script which does this.
I have two local accounts:
thrust
hduser
Now, I am writing Java code in Eclipse in my thrust account.
After the code runs satisfactorily, I do:
mvn clean
cp -r /home/thrust/projectA -r /tmp/
su - hduser
cp -r /tmp/projectA /home/hduser/
cd /home/hduser/projectA
mvn package
Is there a way I can automate all these steps?
Or is there a way I can write code on this thrust account and the code automatically syncs with the hduser account?
Given that you are writing code (and you are doing it "again and again"), it seems you should be using a revision control system (like Subversion or Git), either with a local repository or with a hosting service (for example: GitHub or Bitbucket).
If you don't want to use an RCS, you can create a shell script to automate what you are already doing, as suggested by #iamnotmaynard.
Also, take a look at rsync or ssh. They can help you to copy files from one user to another more easily (rsync can also help you to keep these files synchronized).
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a small shell script that starts a program when I double-click it. (I have set the permissions to allow executing the script).
I want to be able to copy that script to another computer so that the new user can double-click it without needing to know anything about chmod or permissions. But I can't find out how to preserve the execute permission when I copy the file.
I can usually find answers with Google but this has me defeated - I guess I am not expressing my question properly.
Thanks
Use rsync or tar.
rsync -p file user#host:destdir
plus other options you might need.
Or
tar cvzf file.tar file
then copy (or email, etc.) file.tar to the other machine and extract the file:
tar xpvzf file.tar