perl, if directory exists


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl, if directory exists
# 1  
Old 02-18-2012
perl, if directory exists

Hi there

I am trying to make a fuction that looks for a email profile that ends in .$ARGV[0]

here is the code
Code:
if (-d "/Users/$ARGV[0]/Library/Thunderbird/Profiles/*.$ARGV[0]")  {
      print "\n WARNING: Email profile already exits\n\n";
      exit;
      }

but for some reason it does not like the wildcard

any help would be great

thanks
A
# 2  
Old 02-18-2012
Try like...
Code:
if ( ! -e "Index.txt")
{
print "File does not exist\n";
}

# 3  
Old 02-18-2012
That worked like a treat

my new question is how i can find and then write to a certain file

In script is created a users Thunderbird profile which will is located it

Code:
 /Users/$ARGV[0]/]/Library/Thunderbird/Profiles/<RANDOM_STRING>.$ARGV[0]

I am unsure how about getting this directory and then writting to a file called prefs.js

Code:
/Users/$ARGV[0]/]/Library/Thunderbird/Profiles/<RANDOM_STRING>.$ARGV[0]/prefs.js

any pointers would be great
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Check that at least one file exists in the directory.

There are some files with suffix dates like abc_20032019.dat abc_17032019.dat If at least one file exists then perform some operation else exit from execution. Korn shell ---------------------------------- array=($inputdir/abc*.dat) If ] ] then echo " file exits" else echo " file does... (10 Replies)
Discussion started by: Rajesh123
10 Replies

2. Homework & Coursework Questions

Perl CGI: No such file and directory: Yet file exists?

This technically a homework problem but I just need help solving this strange issue. The code is kinda long, I tried posted only the relevant parts. 1. The problem statement, all variables and given/known data: I receive this error: got error No such file or directory (2) at:... (3 Replies)
Discussion started by: jasondancks
3 Replies

3. Shell Programming and Scripting

Check whether file exists in directory

Hi guys, I am beginner trying to learn unix. So any help is welcomed. My requirement is to check whether is a file exists in a particular directory or not. The directory path and filename are taken dynamically with user interaction. So the program should continue only if the $filename... (1 Reply)
Discussion started by: maris_markur
1 Replies

4. Shell Programming and Scripting

How to check if the file exists in directory?

Hi Gurus, I have a requests to find if all the file in the filelist exist in certain directory. example: my filelist abc def ddd cde afg how can I find these 5 files exists at director /home/abc Thanks in advance (7 Replies)
Discussion started by: ken6503
7 Replies

5. Shell Programming and Scripting

script to tell whether there exists directory or not

Hi, I am writing a script as follows: #!/bin/sh set -x for i in `cat a`; do #sleep 3 print $i >> server.txt sleep 5 if test -d `vtask $i "' ls -lrt /opt/log/ '" ` ; then print $i >> 12.5.txt else print $i >> 12.0.txt fi done (7 Replies)
Discussion started by: dbashyam
7 Replies

6. Shell Programming and Scripting

check if directory and file exists

cp $PATHLOGS/$DATE/*.* $TMP/logs_tmp/ cp $PATHLOGS/$DATE1/*.* $TMP/logs_tmp/ Before copying the files I have to check if the directory $DATE1 and $DATE2 exists. If directory exists then, check if the folder contains some files. if the file exists then, check if the file size is greater... (3 Replies)
Discussion started by: sandy1028
3 Replies

7. Shell Programming and Scripting

Problem when test to see if directory exists

Hi, I'm writing a shell script that will create a folder if it does not exist yet. Here's the script: (this if statement is inside a while loop) folderName="Pics" if ! test -d folderName then mkdir $folderName fi However, after the folder Pics has been created, every time the... (3 Replies)
Discussion started by: trivektor
3 Replies

8. UNIX for Dummies Questions & Answers

How can I check if directory exists in a makefile

Hi. I what to write a make file that inside a target I want to check if a directory exists. some like: ### make a: if ;then <command 1> else <command 2> fi ### make end Thanks a lot ---------------------- (2 Replies)
Discussion started by: zivsegal
2 Replies

9. UNIX for Dummies Questions & Answers

Directory exists

Hi all, Sorry about this i'm sure this is a very silly question hence an easy answer but: I'm trying to write a script, part of which I want to check if a directory exists, if it doesn't then create it. Thanks for your help Tez (3 Replies)
Discussion started by: tez
3 Replies

10. Shell Programming and Scripting

check if directory exists

Hi, I need to prompt for a response from a user to enter a path read dest_dir?"Please Enter Directory :" How do I do this until a valid directory is entered by the user. I can use to check the existence of the directory. However when I try the following I cannot get it to work. while ... (2 Replies)
Discussion started by: jerardfjay
2 Replies
Login or Register to Ask a Question