Hello!
I'm stuck with a problem that i can't solve. I'm very new to unix, linux and shell scripting i might add. I'm trying to create a script that will execute as follows:
First start the script - sh exist
Then the prompt asks the user to input a username to check if it exists within the system.
It then checks if the user exists or not.
If the user exist, it returns something like "The user exist" and if the user doesn't exitst it says "The user doesn't exist".
I have tried many different ways to solve this. And where i'm at now looks something like this:
The dir="/home" i understand can be changed to the etc/passwd directory, right? The code complains at the -e command and doesn't like the if statements either. You skilled coders might think i'm stupit to have structured it this way, fell free to right me on this!
Maybe the "read" is completely wrong to use as well?
Thanks for the replies, but i still cant get it to work.
When i use this code:
I get this error: sh-3.2# sh ex
Search user:
Simon
': not a valid identifier
ex: line 8: syntax error near unexpected token `fi'
ex: line 8: `fi'
sh-3.2#
And when i try this code:
I get this error: Simon
': not a valid identifier
: command not found
ex: line 6: -e: command not found
: command not found
user exist!
: command not found
user deosn't exist
ex: line 11: syntax error near unexpected token `fi'
ex: line 11: `fi'
sh-3.2#
I've tried alot of combinations and also to change the directory, but nothing seems to work :/
Any suggestions?
Hi,
I have the below code written. However I am not getting the desired output
I am checking if the particular path has file in it.
#!/bin/bash
ls -l /IRS2/IRS2_ODI/INFILE/*LS* 1>/dev/null 2>/dev/null
if
then
echo $?
echo "File Exists"
fi
... (3 Replies)
Hi All,
I am a beginner in this and trying to write a shell script in linux which will :
1. Ask for a file name and check if its exists.
2. If file exists only then it will ask for the new target folder, after entering target folder name it will check if it exists.
3. If target folder... (3 Replies)
How to check the user input to be valid using shell script?
The valid input is in the format like as follows.
1. It can only have r,w,x or a hyphen and nothing else.
2. ensure the r, w, x are in the correct order.
for example: rwxr-xr-x is a valid format.
Thanks (5 Replies)
Hi
#Testing for file existence
if ; then
echo 'SCHOOL data is available for processing'
else
echo 'SCHOOL DATA IS NOT AVAILABLE FOR PROCESSING'
:
i wrote a script, where it begins by checking if file exists or not.
If it exists, it truncates the database... (2 Replies)
Hi, I'm new to C Shell programming. I'm trying to check if a sym link exists on remote server if not send email. I'm not having much luck. Can anyone help?
Here is what I have written but it doesn't work. It tells me that my variable was not defined. Here is part of the script, the second... (0 Replies)
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)
Hi All,
working on AIX 5.3.
Requirement is:
Shell script in ksh to check if any file exists in 4 folders as below:
1. /FILE/INB/INT1
2. /FILE/INB/INT2
3. /FILE/INB/INT3
4. /FILE/INB/INT4
Thanks a lot for your time!
a1_win. (3 Replies)
Hi friends..
I hav a problem....
I dont know how to check .c files exists r not in a folder using IF in C shell script
actually i tried like this
if(=~ *.c)
even though some .c files or there in the current folder..it is not entering int o the if control statement...... (17 Replies)
Hi all,
I've been trying to find a good check I can put it in to a shell script to see if a given user exists.
Some of the things I've thought about is checking whether they have a home directory, but not all users have a home directory. I've thought about grepping the /etc/passwd file for... (4 Replies)
Hi All,
I am new to shell scripting.
Can someone let me know, how to check whether the user exists in the remote system?
I am building a new unix box and before I proceed installing the appliation , I want to check whether the required users are created in the system .
how to do this ?... (1 Reply)