Checking the valid paths in the shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Checking the valid paths in the shell script
# 1  
Old 12-27-2005
Checking the valid paths in the shell script

Hi i am using a shell script for renaming the files and placing in the remote location(FTP) my code is:
cd $1
day=$(date +%d)
for i in `ls -1 BBW*`
do
last=`tail -1 $i`
pat=`expr "$last" : '.*(\(.*\)).*'`
pat=`echo $pat | sed 's/ /_/'`
pat=$pat$day
mv $i $pat
rm -f $day
done
#!/usr/bin/sh
ftp -v -n "$2" << cmd
user "$3" "$4"
cd $5
mput *_*
bye
cmd
pwd
exit



and parameters(arguments) are
$1(FilePath)=/data/customer/Personal/na
$2(IPAddress)=123.369.45.65
$3(Username)=xvxvxvx
$4(pASSWORD)=*****
$5(FilePath)=/data/man/sub

this is giving output

Requriment:

And also i want to check the file paths are valid paths($1,$5) please tell how to change the script for checking the valid paths.if the filepaths are find invalid i want to stop the executing the script.please give some modification code to check the file paths are valid.
# 2  
Old 12-27-2005
i have posted a wrong answer, pls ignore my message.
# 3  
Old 12-27-2005
is it the $pat that represents the path. if you want to check if this is a valid path use

if [ ! -d $pat ]
then
exit $err
fi
# 4  
Old 12-28-2005
Check the valid file paths in the remote location (FTP)

hi

Thanks for your advise. I want move the files in to remote location(FTP) having a particular filepath. i want check the filepath in the remote location(FTP) is valid. if the path is invalid i want to stop execution of script

code:


#!/usr/bin/sh
ftp -v -n "$2" << cmd
user "$3" "$4"
cd $5
mput *_*
bye




$5 (filepath):data/sas/brg/per

i want to check the file path in remote location(FTP) is valid or invalid.if it is invalid stop the execution of script.please give some advise for my requirement
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help me with C-shell Script: Disk checking

Hi, i am new in shell script. i have given a task to make a C-shell script. I have list of ip address and device name respectively. For example; cal 1 : 100.21.25.10 cal 2 : 100.21.25.11 cal 3 : 100.21.25.12 cal 4 : 100.21.25.14 and so on... Right now, i have this. #! /bin/csh -f ... (0 Replies)
Discussion started by: lattey
0 Replies

2. Shell Programming and Scripting

Service checking through shell script

I want to check the postgres service for client PC which is remotely placed through shell script , whether the Postgres service is working or not.I don't have an idea to develop this script.Please give me a code. Client PC IP Address: 10.66.1.133 (2 Replies)
Discussion started by: kannansoft1985
2 Replies

3. Shell Programming and Scripting

Need a script to check if an argument is valid shell variable

I need a script that should print 'yes' if the argument is a valid shell variable name else 'No' if it is not a valid shell variable. A valid one begins with an alphabet or percentage (%) character and is followed by zero or more alphanumberic or percentage (%) characters. For example: $... (6 Replies)
Discussion started by: pingiliarjun
6 Replies

4. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies

5. Shell Programming and Scripting

How to check the user input to be valid using shell script?

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)
Discussion started by: hyeewang
5 Replies

6. Shell Programming and Scripting

Valid date checking in the file

File contian below data... 20111101 20111102 20111131 I am new to unix and per scirpt... First two records are valid and last record is invalid,how to get the valid records... Please help me unix or perl script. :wall: Thanks, Murali (5 Replies)
Discussion started by: muralikri
5 Replies

7. Shell Programming and Scripting

Checking for a valid MAC Address

I have a ksh script and would like to validate a MAC address that is input by the user: 00:14:4F:FC:00:49 example: MAC=`/usr/bin/ckint -p "Enter MAC address"` echo $MAC echo " " Obviously chkint will not work, but does anyone have any suggestions? Thanks (9 Replies)
Discussion started by: hxman
9 Replies

8. Shell Programming and Scripting

Regularly checking with shell script

Hi, I am new in scripting and also in Linux. I wrote my first script recently. I have an external hdd connected to my debian machine. I am spinning it down using a spindown code (code.google.com/p/spindown/)when I am not using it ( automatically after 1 hour). The problem was I wanted to know when... (2 Replies)
Discussion started by: aspedisca
2 Replies

9. Shell Programming and Scripting

Checking Files with a Shell Script

Hey everyone, I'm writing a shell script that needs to loop thru a directory and check a defined type of files(.df). I use "checkfile.x" which is a compiled program to check those files. Sintaxis : checkfile.x DatefileName.df The program displays something like this: File: kanswer.df -... (1 Reply)
Discussion started by: Testing_Yorsh
1 Replies

10. Shell Programming and Scripting

checking valid values in variable

I'm using the following in my script. if echo $cpuidle |/usr/bin/egrep ; then when I issue this statement it issues the value of the variable back to stdout which ends up in my output file. Is there a better way to write this? I'm using ksh on solaris 9. (3 Replies)
Discussion started by: MizzGail
3 Replies
Login or Register to Ask a Question