Testing using Bash for an unknown extension
I am trying to test to see if a file exsides but the extension changes all the time, ie ab251455.001 ab251455.002 if I do a : if [ -e /var/max/spool/inbound/ab251455.* ] ; then run_command fi the run_command never runs Sean
Sean Rima wrote:
I am trying to test to see if a file exsides but the extension changes all the time, ie
ab251455.001 ab251455.002
if I do a : if [ -e /var/max/spool/inbound/ab251455.* ] ; then run_command fi
the run_command never runs
That's strange. I tried with #!/bin/bash if [ -e ab123.* ] ; then echo "It exists" fi and it works perfectly. Is run_command in the path? -- Vic Ayres
Vic Ayres writes:
Sean Rima wrote:
I am trying to test to see if a file exsides but the extension changes all the time, ie
ab251455.001 ab251455.002
if I do a : if [ -e /var/max/spool/inbound/ab251455.* ] ; then run_command fi
the run_command never runs
That's strange. I tried with #!/bin/bash if [ -e ab123.* ] ; then echo "It exists" fi and it works perfectly. Is run_command in the path?
It is, but I noticed that you didn't include a path, maybe that is why mine is failing, will experiment. Sean
* Sean Rima <sean@tcob1.net> [11-30-03 10:34]:
Vic Ayres writes:
Sean Rima wrote:
I am trying to test to see if a file exsides but the extension changes all the time, ie
ab251455.001 ab251455.002
if I do a : if [ -e /var/max/spool/inbound/ab251455.* ] ; then run_command fi
the run_command never runs
That's strange. I tried with #!/bin/bash if [ -e ab123.* ] ; then echo "It exists" fi and it works perfectly. Is run_command in the path?
It is, but I noticed that you didn't include a path, maybe that is why mine is failing, will experiment.
Then you will have to start the script in the directory that the subject file resides. Have you checked to see if you have read/write access (permission) for the directory where ab251455.00? resides? You might also substitute 'echo "It exists"' for 'run_command' to try to isolate the problem to 'run_command' or '[ -e .... ]'. -- Patrick Shanahan Registered Linux User #207535 http://wahoo.no-ip.org @ http://counter.li.org
Patrick Shanahan writes:
I am trying to test to see if a file exsides but the extension changes all the time, ie
ab251455.001 ab251455.002
if I do a : if [ -e /var/max/spool/inbound/ab251455.* ] ; then run_command fi
the run_command never runs
That's strange. I tried with #!/bin/bash if [ -e ab123.* ] ; then echo "It exists" fi and it works perfectly. Is run_command in the path?
It is, but I noticed that you didn't include a path, maybe that is why mine is failing, will experiment.
Then you will have to start the script in the directory that the subject file resides.
Have you checked to see if you have read/write access (permission) for the directory where ab251455.00? resides?
You might also substitute 'echo "It exists"' for 'run_command' to try to isolate the problem to 'run_command' or '[ -e .... ]'.
I will try these as well as cd'ing to the directory that the files are in first. Sean
Sean Rima wrote:
Vic Ayres writes: <snip>
That's strange. I tried with #!/bin/bash if [ -e ab123.* ] ; then echo "It exists" fi and it works perfectly. Is run_command in the path?
It is, but I noticed that you didn't include a path, maybe that is why mine is failing, will experiment.
I didn't include a path because my script and test file were in my home directory. I wondered if it was a shell expansion issue with the .*. Moving my test file and including the path still works, though. -- Vic Ayres
Vic Ayres writes:
That's strange. I tried with #!/bin/bash if [ -e ab123.* ] ; then echo "It exists" fi and it works perfectly. Is run_command in the path?
It is, but I noticed that you didn't include a path, maybe that is why mine is failing, will experiment.
I didn't include a path because my script and test file were in my home directory. I wondered if it was a shell expansion issue with the .*. Moving my test file and including the path still works, though.
That is strange because if I include the filepath it doesn't work, except the path it works :) Sean
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sun, 30 Nov 2003 15:23:28 +0000 Vic Ayres <vic@ayresonline.co.uk> wrote:
Sean Rima wrote:
I am trying to test to see if a file exsides but the extension changes all the time, ie
ab251455.001 ab251455.002
if I do a : if [ -e /var/max/spool/inbound/ab251455.* ] ; then run_command fi
the run_command never runs
That's strange. I tried with #!/bin/bash if [ -e ab123.* ] ; then echo "It exists" fi and it works perfectly. Is run_command in the path? You might be a bit better off using the for command. #!/bin/bash if [ -e /var/max/spool/inbound/ab251455.* ] ; then LIST=$(ls /var/max/spool/inbound/ab251455.*) for i in $LIST do runcommand $i done fi
This will allow you to issue your command on the individual file. - -- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQE/yhCt+wA+1cUGHqkRAk/oAJsG9um8xgueeBhE8b5Q3dnM7lj6hwCeIHLx AIAWBjY+dOF8QkChIap4Svk= =ELxq -----END PGP SIGNATURE-----
Jerry Feldman writes:
I am trying to test to see if a file exsides but the extension changes all the time, ie
ab251455.001 ab251455.002
if I do a : if [ -e /var/max/spool/inbound/ab251455.* ] ; then run_command fi
the run_command never runs
That's strange. I tried with #!/bin/bash if [ -e ab123.* ] ; then echo "It exists" fi and it works perfectly. Is run_command in the path? You might be a bit better off using the for command. #!/bin/bash if [ -e /var/max/spool/inbound/ab251455.* ] ; then LIST=$(ls /var/max/spool/inbound/ab251455.*) for i in $LIST do runcommand $i done fi
This will allow you to issue your command on the individual file.
I cannot get it to work if there is a path in the test line otherwise this is perfect for something I need to do :) Sean
participants (4)
-
Jerry Feldman
-
Patrick Shanahan
-
Sean Rima
-
Vic Ayres