Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Shell Script Command -- need help!

Posted on 2004-03-29
8
Medium Priority
?
285 Views
Last Modified: 2010-04-17
Greetings!

I am aiming to have a perl script on a test server, to be activated and run once an sql file is scp'd over from a web server.

Basically, I want the shellscript to run every 5 seconds, checking for the sql file on the test server (from the web server).

I have something like this now running on the test server:

while [true] ; do if [ -f pit[it/sq;]; then echo hi; fi; sleep 1; done

What am I doing wrong?  My perl script is not being activated to run.

Any advice or help would be greatly appreciated!  Thanks for your help!

Jamie
0
Comment
Question by:jmc430
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 7

Expert Comment

by:fim32
ID: 10705816
what shell?

and, i'm assuming you typed in that line real quick, as the typos would obviously make it not run...
0
 

Author Comment

by:jmc430
ID: 10705885
Hi!

It's bash shell..

I did type that in without proof- reading ..

The actual line is:

while [ true ] ; do if [ -f output.sql ] ; then echo hi ; fi ; sleep 1; done

Sorry for that previously garbled and illegible line ... !
0
 
LVL 7

Expert Comment

by:fim32
ID: 10705956
and that does nothing for you?  copying and pasting that into my shell (and changing the filename to one that exists) gives me a stream of "hi"s

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:jmc430
ID: 10706431
Hi!

Yes, that does work .. but I was wondering if there were a way to make it so that instead of the stream of "hi's", something like

"perl perlscript.pl"  (replacing the echo hi)

would stop running once it was started once.

Is that possible?

Thanks!
Janice
0
 
LVL 7

Expert Comment

by:fim32
ID: 10706586
hmm, there should be no reason that shouldn't work:

while [ true ]; do
  if [ -f output.sql ]; then
    perl perlscript.pl; # or /path/perlscript.pl if the first line is #!/bin/perl and execute permission
  fi; sleep 1;
done

for that matter, if you replace ther perl line with perl -e 'print "hi\n"', it also works just fine?
0
 

Author Comment

by:jmc430
ID: 10707027
the reason i ask is because when i set "perl perscript.pl" to run, it creates all these pages that continue to be overwritten infinite times,
since every time it finds the output.sql file, it continues to run the perlscript at the same time interval.

it works .. but i wanted it to be a finite sequence of events ..
0
 
LVL 7

Accepted Solution

by:
fim32 earned 640 total points
ID: 10707405
ah so... well, then you got 2 choices...

time it, and then give a little buffer, and set the interval to be greater than that (in hopes that you'll clear it before it runs again)

or, rename the file before you operate on it, either within the perl script or before you call the perl script... it's a kind of lock...
0
 

Author Comment

by:jmc430
ID: 10707693
i like the second choice ... that's a great idea!  (and the one i think i can handle making modifications for).  thanks so much!

=) !

thanks again for all your help!
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Introduction to Processes

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question