hmm.. I stripped all the code, essentially leaving just:
There are other, similar files, I tried to put them into the read loop as well.
For some reason, the shell script hangs when it gets to the while loop for these files. I think the problem may be with the files themselves, not the code.. The files can't be too large, only about 100-300 lines, each with 32 "fields"..
All the variables are working as they should. System just hangs when it gets to the while. I'm still trying to figure out why it hangs... I'll keep this post updated. It's just a typical CSV file with each line being one record.
I don't think it's permissions, all users have at least read permissions: -rwxr--r--
I'm certain it's a file, and not a directory since I can view it in my text editor as a regular csv file.
In "ls -al" there's no "->" link to somewhere else.
From the same directory, I can run commmands like:
cat PEURO03497.1118773120982
and
more PEURO03497.1118773120982
and it opens fine.
This is a long shot but let me try renaming the file.
I enabled "set -vx" so we can see what's going on as it's running... here's the output. (note: i simplified the ls command output..)
HTML Code:
%ls -la
total 560
-rw-r--r-- PEURO03497.1118773120982
-rw-r--r-- PUSA05496.1118776734108
-rw-r--r-- file_names.txt
-rwxr-xr-x test.sh
% test.sh
FIELD1='PBR'
+ FIELD1=PBR
FIELD2=' '
+ FIELD2=
#typeset -i count
while read FILENAME; do
while read RECORD; do
if [ "$FIELD1" = 'PBR' -a "$FIELD2" = ' ' ]; then
count=$(($count + 1))
echo "file->[$FILENAME] count->[${count}]"
fi
done < $FILENAME
done < file_names.txt+ 0< file_names.txt
+ read FILENAME
+
This is where it gets stuck/hangs. Then I have to use kill command to terminate.
The first filename in file_names.txt is "PEURO03497.1118773120982"
I only put two file names into that txt file.. and I copied both files into the same dir as the script. I also tried switching the order in the txt file, same result. The shell let's me do more and cat on them just fine.
I think we've isolated everything except the file contents... perhaps the actual csv data is conflicting in some way.
Hello,
Below I try to control that the input is good an IP :
#!/bin/bash
cp /home/scripts/choice_interfaces.txt /home/scripts/interfaces.txt
chmod 644 /home/scripts/interfaces.txt
echo -e "Please enter the network informations into the /etc/network/interfaces file, complete them below... (9 Replies)
Hi All,
Do you have any sample script,
- auto get file from SFTP remote server and delete file in remove server after downloaded.
- only download specify filename
- auto upload file from local to SFTP remote server and delete local folder file after uploaded
- only upload specify filename
... (3 Replies)
Firstly, I would like to apologize if this is not the appropriate sub-forum to post about GNU/BSD makefile scripting. Though my code is in C++, because I am focusing on the makefile I thought it would go better in shell scripting. Please correct me if I am wrong.
Secondly, I am not interested in... (0 Replies)
how do you write an if statement for something like
if ((expr 1 >= expr 2 && expr 3 >= expr 4) && expr 5 <= expr 6)
if ((TRUE && TRUE) && TRUE) then
condition...
i've done it this way but it doesn't seem to work.
if (] && "$ex_day" -le "$curr_day" ); then
condition... (3 Replies)
Hi, I'm using the && operator in if statement:
if ; then
exp $UID/$PWD@$ORACLE_SID FILE=./DUMP/$TODAY$CONCAT_STR$USERNAME.dmp STATISTICS=NONE LOG=./LOG/$TODAY$CONCAT_STR$USERNAME.log
elif ; then
expdp $UID/$PWD@$ORACLE_SID DIRECTORY=./DUMP/ DUMPFILE=$TODAY$CONCAT_STR$USERNAME.dmp... (8 Replies)
Hi
What is the syntax for if statement using && and || operator?
if && ] ||
here its giving me an error to this if statement
any suggestion?? (2 Replies)
Hello there,
My first time on the forums, glad to be here :)
I'm completely new to programming in PHP and I have a question which I hope someone could help me with.
I am currently using this statement:
if(($session == 2) && ($item == Dagger) && ($item2 == Dagger)){
... (5 Replies)
Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP.
I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Hi All,
Can some one tell me how to get run the following:
data1="hello"
data2="world"
if
then
{
echo "good afternnon"
}
else
{
echo " good morning"
}
fi
The above code gives me an error ad below :
./if.h: line 3: ' (7 Replies)