HOW: Shell script accessing files located in individual logged in user.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting HOW: Shell script accessing files located in individual logged in user.
# 1  
Old 05-02-2011
Java HOW: Shell script accessing files located in individual logged in user.

Hi
I have below scenario, I hope this could be possible, but as of now no idea how to implement this.

Mount point in this location /abc/mp, and there will different users who will be executing one the file shell1.sh file located in /abs/mp, but every user will execute this shell1.sh file from their login
(somtehing like this /aaa/bbb/home/usr1)

I am sure that above step can be implemented by creating link in /abc/mp for each individual users

Now real question is
In my shell1.sh file which is in /abc/mp, have to pick one of the file dynamically (I mean not hardcoded path/file) from certain folder for logged in user

i.e. for example
- File in /abc/mp is shell1.sh
- Individual logged in user is usr1

So usr1 will execute this shell1.sh file using link

The shell1.sh should be able to pick the file namely mydatafile.txt from individual logged in user from certain folder in /aaa/bbb/home/usr1/dump

(Similarly if usr2 executes this shell1.sh then shell file should able to pick mydatafile.txt located in usr2's location that is /aaa/bbb/home/usr2/dump )

I just like to know how this can be implemented, might be very simple but I am not aware of this.

Regards
jc
# 2  
Old 05-02-2011
There is an environmental variable called $HOME which gives the home directory of the currently logged user. Try echo $HOME
Another shortcut is the tilde '~' which refers to the user's home directory. Try echo ~/
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help with running a script on files located in subdirectories

Hello everyone, I'm am a newbie to coding so I am reaching out in hopes that I can get some help from this forum. I am trying to run the script below from a single directory, however the directory has many subfolders. In each of those subfolders is a file, uniquely named to that specific... (3 Replies)
Discussion started by: azurite
3 Replies

2. Shell Programming and Scripting

• Write a shell script that upon invocation shows the time and date and lists all the logged-in user

help me (1 Reply)
Discussion started by: sonu pandey
1 Replies

3. Shell Programming and Scripting

Executing a batch of files within a shell script with option to refire the individual files in batch

Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below. I am on a solaris server btw. Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose. ... (2 Replies)
Discussion started by: goddevil
2 Replies

4. Homework & Coursework Questions

shell to check user is logged on

I was given this to do, Write a Shell script to automatically check that a specified user is logged in to the computer. The program should allow the person running the script to specify the name of the user to be checked, the frequency in seconds at which the script should check. If a... (0 Replies)
Discussion started by: operator
0 Replies

5. Shell Programming and Scripting

Shell script to display user logged last week and time connected

Hello all, I want to display all the user logged last week and know the time tnat they are connected. I have been looking for a solution in the Forum, but I didn't find. Thanks in advance (4 Replies)
Discussion started by: ahernandez
4 Replies

6. UNIX Desktop Questions & Answers

Shell script to display user logged in within given time

how can i know which users have logged in at specified given start and end time in 24 hour format? (3 Replies)
Discussion started by: meherzad4u
3 Replies

7. Shell Programming and Scripting

Get current logged in user from a script run as root.

Ok, so, in order to install some dependencies of a program I made, a script has to be run as root. The thing is that I have to copy some things into the home folder of currently logged in user, but the variable $HOME returns '/root' and the $USER returns 'root' :( Is there any way to see who is... (7 Replies)
Discussion started by: hakermania
7 Replies

8. Shell Programming and Scripting

batch shell script to zip individual files in directory - help

help trying to figure out a batch shell script to zip each file in a directory into its own zip file using this code but it does not work tryed this also nothing seems to work , just ends without zipping any files i have over 3000 files i need to zip up individualy ... (7 Replies)
Discussion started by: wingchun22
7 Replies

9. Shell Programming and Scripting

unix shell script which inserts some records into a file located in remote servers...

All, I need to write an unix shell script which inserts some records into a file located in remote servers. * Get the input from the user and insert according the first row. It should be in ascending order. 123451,XA,ABA 123452,XB,ABB 123453,XC,ABC 123455,XE,ABE 123456,XF,ABF 123458,XG,ABG... (2 Replies)
Discussion started by: techychap
2 Replies

10. Shell Programming and Scripting

script on user who logged in????

writing a script that will check every 5 seconds whether a particular user has logged into the system # Determine if someone is logged on # Version 4.0 if then echo “ Incorrect number of arguments” echo “Usage: $ ison4 <user>” else user=“$1” if who | grep “$user” > /dev/null then... (2 Replies)
Discussion started by: kim187
2 Replies
Login or Register to Ask a Question