f



use of ssh command and to find an entry is a file or directory

Hi
In this script i have to check whether the dest_dir is a file or
directory.
I used -d and -f command to check wether it is a directory or file. I
am getting an error message

E03020134: wc: cannot open famis@falcon.as.ksu.edu:/usr/local/lic/
famis/famd/FMMSource
/usr/local/lic/harvest5/SCRIPTS/deploy2_5.1.1.ksh[59]:
famis@falcon.as.ksu.edu:/usr/local/lic/famis/famd/FMMSource: cannot
open
Pseudo-terminal will not be allocated because stdin is not a
terminal.
I00020133: Warning: no access to tty (Bad file number).
Thus no job control in this shell.
I00020133: Sun Microsystems Inc.	SunOS 5.8	Generic	February 2000
E03020134: if: Expression Syntax.
I00020133: [1] 14416
[1]  + Exit 1                        dir=
============================================================================================================================
E03020134: dir=: Command not found.
/usr/openwin/bin/.: Permission denied.
done: Command not found.
fi: Command not found.
else: endif not found.

 The entry is located on a remote computer. You dont have to login to
access the remote computer. We can directly access the remote
computer.

To access the other computer i use security code which is encryoted in
a file so u dont have to login
 u can directly get in to that system example to copy the file

scp "${HARVEST_WORKDIR}/${item}" "${dest_dir}"
     exit_status=$?
     remote_login=${dest_dir%%@*}
     remote_machine=${dest_dir%%:*}
     remote_machine=${remote_machine#${remote_login}@}
     remote_dir=${dest_dir#${remote_login}@${remote_machine}:}

     if [[ $debug -eq 1 ]] then
         print "remote login: $remote_login"
         print "remote machine: $remote_machine"
         print "remote destination directory: $remote_dir"
     fi

     ### If the copy fails, print the error message
     if [[ $exit_status -ne 0 ]]
     then
         print "Errors copying the file '$s_item'."
         print "Exit status of the copy: ${exit_status}"
         exit 0
     else
         print "'${s_item}' copied into the directory:'${remote_dir}'
on the machine '$remote_machine'"
     fi

     ############## SET PERMISSIONS ########
     if ssh -l ${remote_login} ${remote_machine} "ls ${remote_dir} |
grep ${s_item} > /dev/null"
     then
         if [[ $debug -eq 1 ]] then
             print "executing the remote chmod ..."
         fi
         ssh -l ${remote_login} ${remote_machine} "chmod 664 $
{remote_dir}/${s_item}"
     fi

HARVEST_WORKDIR is the directory where I am working from and item is
the file that is present in HARVEST_WORKDIR and
it has to be copied to dest_dir
its declared as below

 HARVEST_HOME=`echo ~harvest5`
 HARVEST_WORKDIR="${HARVEST_HOME}/workdir"
 HARVEST_SCRIPTS="${HARVEST_HOME}/SCRIPTS"

Actual script

#!/usr/bin/ksh
# to turn on the execution trace
#set -x
# to turn on the debugging messages
debug=0

## Print Usage
if [[ $# -ne 4 ]]
then
    print "deploy2_5.1.1.ksh Usage:"
    print "   deploy2_5.1.1.ksh <environment> <state> <viewpath>
<item>"
fi

## Parameters passed to the script
environment="$1"
state="$2"
viewpath="$3"
item="$4"

## variables used in the script
HARVEST_HOME=`echo ~harvest5`
HARVEST_WORKDIR="${HARVEST_HOME}/workdir"
HARVEST_SCRIPTS="${HARVEST_HOME}/SCRIPTS"
env_nospaces=`print -r ${environment} | sed -e 's/ //g'`
state_nospaces=`print -r ${state} | sed -e 's/ //g'`

if [[ $debug -eq 1 ]] then
    print "Inside the deploy2_5.1.1.ksh"
fi

## Get the destination in the filesystem where
## the files are to be copied.
.. ${HARVEST_SCRIPTS}/get_harvest_dest_info.ksh  "${environment}" "$
{state}" "${viewpath}" "${item}"


    remote_login=${dest_dir%%@*}
    remote_machine=${dest_dir%%:*}
    remote_machine=${remote_machine#${remote_login}@}
    ssh ${remote_login}@${remote_machine} <<-EOF
    if [ -d "${dest_dir}" ]; then
    rtype=DIR
    elif [ -f "${dest_dir}"]; then
    rtype=REG
    else
    rtype=BAD
    fi
    EOF

## To find the destination is a  directory
if [ $rtype==DIR ]; then
     print "The destination is a directory"
     . ${HARVEST_SCRIPTS}/deploy_3.ksh  "${environment}" "${state}" "$
{viewpath}" "${item}"


## To find the destination is a file
elif [ $rtype==REG]; then
     print "The destination is a file"
     # count=$(wc -l ${dest_dir})

## To check whether the file is empty
     # if ((count == 0)) then
     if [ wc -l ${dest_dir} -eq 0 ]; then
     print "file is empty: It should contain some entrys"
     else
     dest_dir1=${dest_dir}
     cat ${dest_dir1} |   \
     # while IFS=read -r line
     while read line
     do
     	echo "Found line: $line"
     	dest_dir=&line
     	. ${HARVEST_SCRIPTS}/deploy_3.ksh  "${environment}" "${state}" "$
{viewpath}" "${item}"
done
     fi

 ## When a file does not exist copy the file with the same name
else
print "File does not exist"
# file_name='basename dest_dir'
# dest_dir='dirname dest_dir'
.. ${HARVEST_SCRIPTS}/deploy_3.ksh  "${environment}" "${state}" "$
{viewpath}" "${item}"

fi

Is there any other way to find whether it is a file or directory

0
3/8/2007 7:00:12 PM
comp.unix.shell 15484 articles. 2 followers. Post Follow

3 Replies
677 Views

Similar Articles

[PageSpeed] 5

I have also tried to use ssh -l ${remote_login} ${remote_machine} <<-
EOF

I still get the same error message

when I tried this
ssh -t ${remote_login} ${remote_machine} <<-EOF
I got an error message below
E03020134: wc: cannot open famis@falcon.as.ksu.edu:/usr/local/lic/
famis/famd/FMMSource
/usr/local/lic/harvest5/SCRIPTS/deploy2_5.1.1.ksh[59]:
famis@falcon.as.ksu.edu:/usr/local/lic/famis/famd/FMMSource: cannot
open
Pseudo-terminal will not be allocated because stdin is not a
terminal.
E03020134: Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password,keyboard-interactive).

0
nitesh
3/8/2007 7:32:55 PM
In article <1173380412.213580.56560@j27g2000cwj.googlegroups.com>,
 "nitesh.reddy@gmail.com" <nitesh.reddy@gmail.com> wrote:

> Hi
> In this script i have to check whether the dest_dir is a file or
> directory.
> I used -d and -f command to check wether it is a directory or file. I
> am getting an error message
> 
[snip]

> Actual script
> 
> #!/usr/bin/ksh
> # to turn on the execution trace
> #set -x
> # to turn on the debugging messages
> debug=0
> 
> ## Print Usage
> if [[ $# -ne 4 ]]
> then
>     print "deploy2_5.1.1.ksh Usage:"
>     print "   deploy2_5.1.1.ksh <environment> <state> <viewpath>
> <item>"
> fi
> 
> ## Parameters passed to the script
> environment="$1"
> state="$2"
> viewpath="$3"
> item="$4"
> 
> ## variables used in the script
> HARVEST_HOME=`echo ~harvest5`
> HARVEST_WORKDIR="${HARVEST_HOME}/workdir"
> HARVEST_SCRIPTS="${HARVEST_HOME}/SCRIPTS"
> env_nospaces=`print -r ${environment} | sed -e 's/ //g'`
> state_nospaces=`print -r ${state} | sed -e 's/ //g'`
> 
> if [[ $debug -eq 1 ]] then
>     print "Inside the deploy2_5.1.1.ksh"
> fi
> 
> ## Get the destination in the filesystem where
> ## the files are to be copied.
> . ${HARVEST_SCRIPTS}/get_harvest_dest_info.ksh  "${environment}" "$
> {state}" "${viewpath}" "${item}"
> 
> 
>     remote_login=${dest_dir%%@*}
>     remote_machine=${dest_dir%%:*}
>     remote_machine=${remote_machine#${remote_login}@}
>     ssh ${remote_login}@${remote_machine} <<-EOF
>     if [ -d "${dest_dir}" ]; then
>     rtype=DIR
>     elif [ -f "${dest_dir}"]; then

You're missing the required space before ].

>     rtype=REG
>     else
>     rtype=BAD
>     fi
>     EOF

This sets variables on the REMOTE machine, not the local machine.  Maybe 
something like this is what you want:

rtype=`ssh ${remote_login}@${remote_machine} <<EOF
if [ -d "${dest_dir}" ]; then
echo DIR
elif [ -f "${dest_dir}" ]; then
echo REG
else
echo BAD
fi
EOF
`

> 
> ## To find the destination is a  directory
> if [ $rtype==DIR ]; then

It should be =, not ==, and you need spaces around it.

>      print "The destination is a directory"
>      . ${HARVEST_SCRIPTS}/deploy_3.ksh  "${environment}" "${state}" "$
> {viewpath}" "${item}"
> 
> 
> ## To find the destination is a file
> elif [ $rtype==REG]; then

Again it should be =, and you need spaces around it and before ].

>      print "The destination is a file"
>      # count=$(wc -l ${dest_dir})
> 
> ## To check whether the file is empty
>      # if ((count == 0)) then
>      if [ wc -l ${dest_dir} -eq 0 ]; then

That should be

if [ `wc -l "${dest_dir}"` -eq 0 ]; then

>      print "file is empty: It should contain some entrys"
>      else
>      dest_dir1=${dest_dir}
>      cat ${dest_dir1} |   \
>      # while IFS=read -r line
>      while read line
>      do
>      	echo "Found line: $line"
>      	dest_dir=&line
>      	. ${HARVEST_SCRIPTS}/deploy_3.ksh  "${environment}" "${state}" "$
> {viewpath}" "${item}"
> done
>      fi
> 
>  ## When a file does not exist copy the file with the same name
> else
> print "File does not exist"
> # file_name='basename dest_dir'
> # dest_dir='dirname dest_dir'
> . ${HARVEST_SCRIPTS}/deploy_3.ksh  "${environment}" "${state}" "$
> {viewpath}" "${item}"
> 
> fi
> 
> Is there any other way to find whether it is a file or directory

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
0
Barry
3/9/2007 4:05:40 AM
Barry Margolin <barmar@alum.mit.edu> wrote, on Thu, 08 Mar 2007:

>>      print "The destination is a file"
>>      # count=$(wc -l ${dest_dir})
>> 
>> ## To check whether the file is empty
>>      # if ((count == 0)) then
>>      if [ wc -l ${dest_dir} -eq 0 ]; then
> 
> That should be
> 
> if [ `wc -l "${dest_dir}"` -eq 0 ]; then

There are more problems than just the missing ` and " ...

"wc -l filename" will output the file name as well as the count; solved
by using "wc -l < filename".

The comment indicates that the intention is to check whether the file
is empty, but "wc -l" will output 0 for non-empty files if they don't
contain any newlines; solved by using "wc -c".

If the file cannot be read, wc will produce no output and the "["
utility will be invoked as "[ -eq 0 ]" which is a syntax error.
This can't be solved by just double-quoting the substitution because
wc can output leading blanks, which the "-eq" operator of "[" need
not accept.  In a POSIX shell this can be solved using an
arithmetic expansion, e.g.:

  if [ $(( $(wc -c < ${dest_dir})+0 )) -eq 0 ]; then

This is a robust solution using wc, but it is inefficient: if the file
is large, it will read the whole thing.  The best way to solve that is
to abandon wc and just use:

  if [ ! -s "${dest_dir}" ]; then

-- 
Geoff Clare <netnews@gclare.org.uk>

0
Geoff
3/12/2007 2:16:20 PM
Reply:

Similar Artilces:

How to use command in text file from shell script file
Hi, I am trying to load commands from a text file to variable and use that variable as part of command. code file content , test.txt: -------------------------------------- | grep -iv ",x_pt/js/ah contract,16 Sep 2007" | grep -iv ",x_deductshift,16 Sep 2007" sh file --------- #!/bin/ksh ################################################################# # Program Name ################################################################# PROG_NM="EA Log Pre/Post file Comparison" ################################################################# # Set up environment ################################################################# HOME=/hz/homedev/samigdev/saff5/Saff5Mig FB=${HOME} SCRIPTS=${FB}/Src/Scripts SCRIPTLOG=FilterFilesTest.log TEMP=${HOME}/Temp LOG_HIST=${HOME}/History/Logs ANT=${HOME}/ant ANT_HOME=/hz/homedev/samigdev/ant export ANT_HOME ORA=/appl/oracle/8.1.7 JAVA=/usr/java130:/usr/java130/jre/bin:/usr/java130/jre/bin/classic:/ usr/lib LINE=`tr '\n' ' ' < ${TEMP}/test.txt` CMD="cat ${TEMP}/AccountBalanceAfter.log ${LINE}" # Set the PATH PATH=${PATH}:$ANT_HOME/bin:${ORA}:${JAVA}:${HOME}/lib/xerces123.jar:$ {HOME}/lib/jdom.jar:${HOME}/lib/log4j1.1.1.jar:/appl/oracle/8.1.7/lib:/ usr/local/bin:/usr/bin:/etc:/usr/sbin:/usr/java130/bin:/appl/oracle/ 8.1.7/bin:/appl/oracle/8.1.7/lib:/appl/oracle/8.1.7/jdbc/lib/:/usr/ ucb:a:/usr/bin/X11:/sbin:/appl/oracle/8.1.7/jdbc/lib/classes12.zip:/ appl/oracle/8.1.7/jdbc/lib/nl...

[vim] using a line in a file as shell command for output into same file
I have a file that quotes some linux commands, and want to be able to run that command from within the file and have the output come below it. For example, some lines in the file might be: blah blah $ vim --version | head -n 1 - I'll move the cursor to the line with the command on it, then hit some bound key, and want the output to look like this: blah blah $ vim --version | head -n 1 - VIM - Vi IMproved 7.1 (2007 May 12, compiled Oct 31 2007 06:25:17) I know I can read the output of the command by pasting it on the vim commandline with :r!command but I'm not sure h...

Using File::Find and only manipulating 1 file per directory.
I am rather new to Perl and I'm looking for a little direction. How can I use File::Find to step recursively through a directory tree and then only manipulate *one* file per directory it encounters. What I am trying to do specifically is copy the first image file in each directory up to the next highest directory ("../"). Then I'd like to rename it with the directory name it came from (in other words, copy it from "/images/image1.jpg" to "/images.jpg") I am able to copy *all* images to the next highest directory using the following code: #!/usr/bin/pe...

Using File::Find to delete files and directories older than 30 days
I am a Perl beginner and I hve writen this script to remove files older than 30 days, it works well EXCEPT that it leave the empty directories behind, can anyone help me look for empty directories and remove them as well? TIA, Steve #! Perl -w use Strict; use File::Find; $tempdir = "D:\\shared dirs\\temp Public"; find(\&Wanted, $tempdir); sub Wanted { #Do not scan Purchasing or Budget return $File::Find::prune = 1 if $_ eq "Purchasing - Do Not Remove"; return $File::Find::prune = 1 if $_ eq "BUDGET"; # only on files older than 30 days if ( ( -M $_ ) > 30 ) { @args = ("del", "/F", "/Q", "$_"); system @args; } } SteveO <stevehobrien@hotmail.com> wrote: > I am a Perl beginner Have you seen the Posting Guidelines that are posted here frequently? > to remove files older > than 30 days, it works well EXCEPT that it leave the empty directories > behind, > #! Perl -w > use Strict; > use File::Find; > $tempdir = "D:\\shared dirs\\temp Public"; That should fail to compile under strictures, you did not declare $tempdir. use strict; Case matters. use warnings; is better than the -w switch If you use single quotes, then you won't have backslash the backslashes: my $tempdir = 'D:\shared dirs\temp Public'; Or, better yet, use sensible slashes instead of silly slashes: my $tempdir = 'D:/shared dirs/temp Public'; &g...

How to use get the current directory name from use bash shell commands?
Hi, I need the current directory name and use it in a Makefile. Would you please help me how to do it? Thanks! Best wishes, Peng -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 PengYu.UT@gmail.com wrote: > Hi, > > I need the current directory name and use it in a Makefile. Would you > please help me how to do it? Thanks! pwd - -- Lew Pitcher IT Specialist, Enterprise Data Systems, Enterprise Technology Solutions, TD Bank Financial Group (Opinions expressed are my own, not my employers') -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) iD8DBQFCf6TVagVFX4UWr64RAicvAKC9wBWpjGqXg4M95n9n/4K0kptBOACgpJYW BxUFUhEIdsyVgkS1CFfD0WU= =80In -----END PGP SIGNATURE----- PengYu.UT@gmail.com wrote: > Hi, > > I need the current directory name and use it in a Makefile. Would you > please help me how to do it? Thanks! > > Best wishes, > Peng the bash shell command for getting the current directory is pwd [p]rint {w]orking [d]irectory PengYu.UT@gmail.com wrote: > Hi, > > I need the current directory name and use it in a Makefile. Would you > please help me how to do it? Thanks! > > Best wishes, > Peng > Full path: pwd=`pwd` echo "$pwd" Just the directory name: dir=`basename "$pwd"` echo "$dir" Regards, Ed. On Mon, 09 May 2005 at 18:03 GMT, PengYu.UT@gmail.com wrote: > Hi, > > I need the current directory name and use it in a Makefile. Would you > p...

Using File:Stat.mode method to find file permissions in Unix
Hi, I am trying to find the permissions on a file, using mode method of File:Stat. Code : s = File.stat(file_name) p s.mode For a file having 777 permissions, this prints : 16895 Any Idea on what does this number imply ? Thanks, Vikram -- Posted via http://www.ruby-forum.com/. Vikram Sharma wrote: > Hi, > > I am trying to find the permissions on a file, using mode method of > File:Stat. > > Code : > > s = File.stat(file_name) > p s.mode > > For a file having 777 permissions, this prints : 16895 > > Any Idea on what does this n...

use file::find to find files modified in last 5 days
I have written a script to find files I now want to be able to pass it a days parameter and only show files modified in the last x days How do I do this My script so far is below use strict; use lib 'jumi'; use WebLib; use File::Find; use File::Basename; my ( $folder, $tofind, $tofile, $exclude, $cs ) = @ARGV; my @tofind = split '&&',$tofind; #strip whitespace @tofind = grep(s/\s*$//g, @tofind); @tofind = grep(s/^\s*//g, @tofind); foreach(@tofind) {print "|$_|<br>";} print "<p>Excluded:<br>$exclude</p>"; find(\&wa...

exlude files and directory using tar command
Hi, I am wondering how can I exclude directories and files while taring up? I used --exclude with few options but did not work. Any help would be appreciated. Thanks I tried few options like the below to test it out. I want to exclude dont and nodir directories?? bash-2.03$ tar -cvf --exclude dont, nodir mytar.tar * tar: dont,: No such file or directory a nodir/ 0K tar: mytar.tar: No such file or directory a --exlude 26K a -x 13K a dont/ 0K a filex1 0K a filex2 0K a five 0K a four 0K a nodir/ 0K a one 0K a six 0K a three 0K a two 6K bash-2.03$ tar -cvf -x dont, nodir mytar.tar * tar: ...

Finding all the links in a Unix file/directory path
Hi, I am working on a Perl script that copies files from a log file. Some of the files are links. The link however is in an intermediate directory. For example, in a path /tmp/test_hier/b/f/of3.cpp, the actual path is /tmp/test_hier/b/c/of3.cpp. I have attached a DirGen.pm that creates the sample directory hierarchy and a DirGen.t that prints out the information that the file is a link. My Questions: 1) Does anyone know how I can recursively trace the links so that I copy the "exact" hierarchy? For example, I want to copy *everything* in /tmp/test_hier underneath /tmp/copy/tmp/t...

How to use find command and exclude some files in the same time?
Hi, I want to find files which has be modified in last 60 minutes. I use: find . -type -f -mmin -60 It works well. However, I hope to improve one more step. I want my command print out files that have been changed. Those files are like *.java file, *.txt file or some other files. BUT, not *.class files, because *.class files are generated automatically each time I compile my Java program. I know they are new files. I am not interested in finding them out as new files. I don't know how to exclude them in my find command. Thank you very much. 2007-01-24, 11:30(-05), www: > Hi, ...

find command and excluding files under specific directories
Help with find and excluding files under specific directories. For these specific dirs, I want to exclude all files under, but keep the directory names. /opt/2004/jan /opt/2004/feb/logs /opt/2004/mar/outs Could someone please tell me the correct syntax I should use for my find command? And don't tell me to read the man pages, because I've done that! Cheers! you can try this find /opt/2004 -type d -print -SR Sun, That will exclude the entire directory /opt/2004 and everything under it. I need to keep the directory structure, and remove files "under". Cheers! shpot4@yahoo.com wrote: >>> Help with find and excluding files under specific directories. >>> For these specific dirs, I want to exclude all files under, but keep >>> the directory names. >> >> find /opt/2004 -type d -print > > That will exclude the entire directory /opt/2004 and everything under > it. I need to keep the directory structure, and remove files "under". First, please keep some of what you are referring to when replying! It makes reading so much easier. Second, That will NOT exclude the entire directory /opt/2004. Did you try it? Maybe the response was not what you needed, but it is hard to tell as you do not make yourself clear: - What exactly do you want to find? - What are 'specific directories'? - Is a directory a file? If you cannot explain it, maybe you can provide an example (before/after) detaile...

How to find regexp in a directory / Use grep on multiple files??
Hi, I wonder how I can use grep to find a regexp in more than one file: I would like to look through all files in let's say a web depository (containing subdirectories) and turn out the ones containing the regexp i'm looking for. So if someone could turn up with some magic command doing: $ magiccommand "regexp_im_looking_for" ./in_this_directory and would give a result similar to file_name line_number file_name_2 line_number_2 that would really be great. Thanks for any help Matthias hultsfret wrote: > Hi, > I wonder how I can use grep to find a regexp in mor...

Searching Windows Directories Using Unix Shell Script
Hi, I want to get inputs from you all, if below task can be done through batch scripting or VB scripting. I have a unix script currently running on Sun Solaris (SunOS 5.10 Generic_142900-15 sun4u sparc SUNW,Sun-Fire-V440). This script takes directory name as input and searches for some patterns (both Regular expression based and strings) in all files and directories under the passed directory location. My questions are =96 1) Can I use this unix script to search the patterns on windows? Basically I want to pass windows directory location and get the output. 2) If yes, how to go about it? Appreciate your inputs. On Oct 20, 5:06=A0pm, Raj <rajpreetsi...@gmail.com> wrote: > Hi, > > I want to get inputs from you all, if below task can be done through > batch scripting or VB scripting. > > I have a unix script currently running on Sun Solaris (SunOS 5.10 > Generic_142900-15 sun4u sparc SUNW,Sun-Fire-V440). This script takes > directory name as input and searches for some patterns (both Regular > expression based and strings) in all files and directories under the > passed directory location. > My questions are =96 > 1) =A0 =A0 =A0Can I use this unix script to search the patterns on window= s? > Basically I want to pass windows directory location and get the > output. > 2) =A0 =A0 =A0If yes, how to go about it? > > Appreciate your inputs. There might be several ways you can do it. Some commonly used tool...

Can I use LS command to only list files and not directories
I want to use the "ls" command to only list files. I see a -d option to only list directories, but I just want a file listing. Is this available with the ls command or do I have to loop through the directory and do a [if -f] and pipe the name of the file to an output file ? Thanks. In article <f0bb0f39.0310291036.72536ad0@posting.google.com>, newexpectuser <anthonypieper@cs.com> wrote: >I want to use the "ls" command to only list files. I see a -d option >to only list directories, but I just want a file listing. > >Is this available with the ls co...

Recursive invocation of a unix command on multiple files under a directory
Does anyone have a suggestion regarding the best way to recursively invoke the same command (for example dos2unix or chmod) on all the files under a directory? I started out by using find [ something like find . -type f -exec COMMAND {} \; ]. This approach works fine with commands that operate on the same file (e.g. chmod), but I am having trouble with commands like dos2unix that do not operate on the same file, but send their output to the stdout instead (i.e the filters). -Nimmi <nimmi_srivastav@yahoo.com> wrote in <1098866807.487903.157250@z14g2000cwz.googlegroups.com>: &g...

Getting all directories/files from current directory and using -d flag for the directories
Hi guys/gals, I'm pretty new to Perl, so please keep that in mind. :) It looks like File::Find goes through all the subdirectories of the current directory, which isn't what I want. I just want all the contents of the current directory. On doing some research, many people have recommended doing something like the following: ----------- $home_dir = ''; #changed to protect the innocent :) opendir(DIR,$home_dir) or die "Can't open the current directory: $home_dir $!\n"; # read file/directory names in that directory into @names @names = readdir(DIR) or die "...

Iteration through File.file? misses entries for which File.file?(entry) == true
Hello everyone, I'm new to Ruby, so I'm most likely making an elementary mistake. However, searching Google didn't help me find my answer, and after mucking around with irb I still haven't figured it out. I wrote a method that was intended to take all of the files in a given directory and put them into an array. Here's the code I wrote: def getFiles(dir) pwdFiles = Array.new Dir.foreach(dir) do |entry| pwdFiles.push(entry) if File.file?(entry) == true end end This works fine when called on the working directory --- that is, getFile...

How to use multiple command with in Find command?
Hi all, I have a problem while executing multiple command with in a Find command. Actually my requirement is to find a file in a specific directory and remove it and want to create a file with the same name which I have searched for. Here is what I am doing find Desktop/Test -name test -exec rm -rf {} \; -exec touch {}/test \; From the above command first command is executing successfully. But when comes to touch command it was not creating file. Is there any thing wrong under touch syntax or expressions? Can any one please help me. Also please suggest me if there are any easy ...

finding line no of a STRING in a text file using shell script.
Hi Good morning to All, I have the following requirement. Pl, Help me in solving this problem. The requirement is I have to text file with 10 lines. Ex : [ Smoking, eatables will not be allowed inside the facility. Mobile phones are not to be carried inside the facility. Membership cards to be carried always and displayed on request by the Gym admin staff. Personal guests will not be allowed inside the Gym. The music system will be handled by the Gym staff only. Personal request will not be entertained. On completion of workout, users are requested to replace the equipments viz stabi...

Using Shell Execute command to print contents of text file
I have an application where I want VB to send the contents of a text file to my default printer. After doing a google search, I found the syntax for the shell execute command. Here is the code I am using: ShellExecute 0, "Print", "D:\batch_files\list_tasks\list.rtf", "", "", 0 When I run my VB program, nothing happens. Perhaps someone with experience using this command can point out anything obvious. Thanks On 25 Aug 2004 21:55:15 -0700, techman41973@yahoo.com (Joe Blo) wrote: >I have an application where I want VB to send the contents of a text >file to my default printer. After doing a google search, I found the >syntax for the shell execute command. Here is the code I am using: > >ShellExecute 0, "Print", "D:\batch_files\list_tasks\list.rtf", "", "", >0 > >When I run my VB program, nothing happens. Perhaps someone with >experience using this command can point out anything obvious. Thanks > What OS is this on and have you got Office or Word installed ? On my machine with XP, but without Office installed it works fine, i suppose Wordpad must be handling it. However this is how i do it : ret = ShellExecute(0&, "print", "yourfile.rtf", vbNullString, vbNullString, 0&) if ret < 32 Then Debug.Print Err.LastDllError else Debug.Print " printing..." End If If debug prints dllerror '1155', then you have nothing ...

What Emacs Commands Do You Use Most and Find Most Useful?
I'm just curious what commands and features experienced emacs users use most often and find most useful. Nick Mudge wrote: > I'm just curious what commands and features experienced emacs users > use most often and find most useful. The emacs feature not found in other editors that I find the most useful is the keyboard macro. I also use copy/cut/paste with the 3 mouse buttons constantly. At Tue, 19 May 2009 07:01:28 -0700 (PDT), Nick Mudge <mudgen@gmail.com> wrote: > > I'm just curious what commands and features experienced emacs users > use most often a...

files, directories, files, directories
Hi folks, I've been trying to make a decision and it's driving me crazy. Is a directory a file or is a directory NOT a file but a node? Should I have A) public interface IFile { IFileName FileName; IContent GetContent(); } public interface IDirectory extends IFile { } or B) public interface INode { INodeName NodeName; } public interface IFile extends INode { IContent GetContent(); } public interface IDirectory extends INode { } Method A is nice cause IFile becomes the base "Node" type and you can use names like "IFileName" which sounds nice compared to "INodeName" and fits with the "FileSystem" moniker. A has the disadvantage that IDirectory has a GetContent() method which isn't bad but can be considered a bit weird. It probably wouldn't be too hard to make users think of everything as a file. Method B is nice cause IDirectory doesn't have GetContent() -- that honour belongs only to IFile. B is at a disadvantage when it comes to naming: everything becomes a "Node". INodeName sounds rude compared to IFileName. This method feels more "pure" cause you're specialising features completely. Do you reckon I can get away with Method A? It doesn't seem as pure unless you spend a long time convincing yourself that (for all intents and purposes) a file *is* a node (it's just got a different name) and a directory *is* a file. A penny for anyone's thought...

Unix Command Line
Now, you may think. What is so special about the FIND command? It is just= a pretty straight forward command. You tell it what to search for, and it= finds it for you. You give it some criteria and it weeds out anything tha= t does not match that criteria. The criteria usually will result with fewe= r files to allow you to choose from. Or. you may have the option to use a = wild card character which usually results in more files to choose from. But, what if, I told you that the FIND command is the back bone to how a ba= tch file works. For example, you can use the FIND command to find all file= s of a type $C1, which are graphic files, and then have a slide show, no ma= tter where they are stored. You can FIND all the Finder.data files on a ha= rd drive, then delete them all. You can FIND all files that start with a p= art of a name, and lock/unlock them all. That is kinda/sorta what this FIND command does. It finds all files that m= atch your criteria, and has the ability to store the results in a text file= .. You can then edit the text file and put a disk command (delete, lock, un= lock, view) in front of each prefix, then EXEC the text file. Yes, VIEW, c= an even be used when the UNIX command line is installed. It allows you to = view most graphics. A couple of notes on the FIND command should be mentioned. FIND does not u= se the MLI OPEN function. So it will not work on network disks. It reads = from a block device, which make...

use "find files" as command instead of interactively
Hi! I want to use the 'find files' search engine from Matlab as a command to search for files in a list (also in subfolders). For example for i=1:length(list) destination(i) = findfile(file(i)); end Is there a possibility to use this function as a command? Or does anyone know a user-built function (search engine) or a windows based application that i can run from command window? Thanks for help! I found a solution for Windows systems using the "dir" command: [status,result] = dos(['dir "',filename,'" /S /B']); Use the quotation marks for fil...

Web resources about - use of ssh command and to find an entry is a file or directory - comp.unix.shell

Wikipedia:Quick directory - Wikipedia, the free encyclopedia
This page is a handy directory to various locations of interest in Wikipedia. Only dynamic pages should be listed here, no policy pages etc. ...

Telephone directory - Wikipedia, the free encyclopedia
"Phone book" and "White pages" redirect here. For a contact list, see Contact list . For other uses, see White pages (disambiguation) . Subscriber ...

Don't call us: Centrelink bosses remove phone numbers and email from directory
Tom was savvy enough to take his complaints straight to Centrelink management.

Don't call us: Centrelink bosses remove phone numbers and email from directory
Tom was savvy enough to take his complaints straight to Centrelink management.

Don't call us: Centrelink bosses remove phone numbers and email from directory
Tom was savvy enough to take his complaints straight to Centrelink management.

Business Directory Listings: Eight Smart Tips for You to Get Started
If you are considering a business directory listing for your small business, congratulations – you are on the right track. Local SEO, local customers, ...

Atlas Partner Directory Launched
... just for Facebook and Instagram –advertising platform Atlas has one, as well. On that note, Atlas Tuesday introduced the Atlas Partner Directory ...

Slack announces App Directory store
... create more apps for the store, and a new framework called Botkit which should simplify the process of creating apps. The Slack App Directory, ...

Amazon brings Microsoft users into AWS with Active Directory service
Amazon has launched an AWS Directory Service for Active Directory , a fully managed implementation of Microsoft's authentication and user management ...

Hackers leak DHS staff directory, claim DOJ is next
On Sunday, an account on Twitter posted a Department of Homeland Security staff directory with 9,355 names. Shortly after the DHS data was posted, ...

Resources last updated: 3/29/2016 1:56:56 AM