create a directory at user home using shell script
Solaris / OpenSolarisThis forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.
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.
create a directory at user home using shell script
I am trying for creating a "test" directory in user home using shell script as follows
mkdir -p ~/test
But it creates ~/test directory at script executing path instead of creating "test" directory in user home . But when i run "mkdir -p ~/test" on terminal then it creates test directory successfully in user home .
OK, so you are logged in as root, root's home directory is / and $HOME is correctly set. We still don't know which shell root is using so please post the output of
Code:
grep '^root:' /etc/passwd | cut -d':' -f7
Going back to your OP
Quote:
mkdir -p ~/test
But it creates ~/test directory at script executing path instead of creating "test" directory in user home . But when i run "mkdir -p ~/test" on terminal then it creates test directory successfully in user home.
How had you got to the command prompt when you ran the command the first time? Were you using a terminal emulator in the graphical environment?
Please post a copy-and-paste of doing that so we can see exactly what happened, along with "extras". Something like this.
When you wrote "But when i run "mkdir -p ~/test" on terminal" what do you mean by "terminal"? Do you mean one of the virtual terminals, normally accessed via Ctrl+Alt+F<1 to 6>? If you can do so, please post a copy-and-paste of doing the same as above at your "terminal" command prompt. If you can't do that, please post what is different.
When your wrote "But when i run "mkdir -p ~/test" on terminal then it creates test directory successfully in user home", do you mean directory /test was created?
Last edited by catkin; 04-30-2010 at 01:16 AM.
Reason: typoanarchy
When your wrote "But when i run "mkdir -p ~/test" on terminal then it creates test directory successfully in user home", do you mean directory /test was created?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.