How to automatically google a string periodically from a shell script?
I am trying to figure out the best way to automatically google search on a certain given string, periodically (say once per hour). I think I can set up the launchd script properly, but am wondering how one might use curl or wget to search a specific string (say, for example, the Fourth Amendment to the US Constitution).
I figure it might be nice to have that firmly in my database.
Hey Bill,
There are many ways to do this in unix. Here's a wget example:
Note, first I got the URL that google would use to search for the 4th amendment, this is:
http://www.google.com/search?client=opera&rls=en&q=4th+amendment&sourceid=opera& ie=utf-8&oe=utf-8
Next I shrunk it down to a more manageable size using www.tinyURL.com to:
http://tinyurl.com/9fb35
now for wget you could run, say:
google_search=`wget -q -O- -U opera "http://tinyurl.com/9fb35"`
(I'm using bash here, so you'll have to change the assignment syntax for a different shell)
What's important here is the "-U opera" flag to wget. This sets wget to identify as a specific user:agent, and without it, Google search will return a 404. Also, instead of making a tinyURL out of that whole URL, I could have used:
http://www.google.com/search?q=4th+amendment
but I like using tinyURLs, and with a long-ish seach query it becomes useful very quickly.
Now, with curl you could use:
google_search=`curl -s -A opera "http://www.google.com/search?q=4th+amendment"`
The user:agent flag is important when using curl with the Google search also, since you'll get a 404 (albeit a strange one) if you don't. Also, curl doesn't seem to want to play well with the tinyURL redirection.
What you could do instead of use the tinyURL is set the URL to a variable, like;
searchurl="http://www.google.com/search?q=4th+amendment"
then you could simply run the command:
google_search=`curl -s -A opera "${searchurl}`
Hope this helps!
Powerbook G4 Mac OS X (10.4.4) 1.25 GHz, 1GB RAM
Similar Messages
-
Debugging a program being called from a shell script
hi All,
i want to know how debug a C program being called from A Shell Script,
my script looks like the following :
ecReqProcMain $Cfg/ecReq.g $TotCnt 2>> $ErrFilei also have to pass some arguments to the script itsellft, which in trun going to pass it to the program,
also in some cases i may be required to Pipe some data to the program, like the folowing
cat DataFile | myProgramThanks ,You can also use ss_attach with the scheme that Anton
suggested above. Instead of inserting "dbx" into your
script, insert "ss_attach" into your script.
It's also possible to change your script to something like this:
cat DataFile | ${DEBUG} myProgram
Then you can run your script like this:
setenv DEBUG ss_attach
ecReqProcMain $Cfg/ecReq.g $TotCnt 2>> $ErrFile
--chris -
How to check from a shell script that a particular software is installed
Hai friends
I want to write a shell script which has to check whether a particular software is installed on the machine, or not. If installed, then what version is it using and the get the version number and which type of installer is it? i mean is it a .rpm installation or a tar.gz installation.
how can i check this from a shell script. If any of you have any idea please give me a sample script to check this
Thank you@Raja_Abilash
I don't think this is a right thread & right forum to POST this question.
better go ahead with forums related to LINUX. -
How to mark build as partially succeed from pre-build script
Hello,
is there a way how to mark build as partially succeed from pre-build script?
And, also insert some text in Build Summary? (Other Errors and Warnings area will be fine)
I was trying to use "Write-Error "My Test Error" -ErrorAction SilentlyContinue" but it is not working.
Thanks,
JiriHi Jiri,
I think John's reply in this thread will be helpful to you. The short answer is that your pre-build script should return a value to indicate whether the script success or not. Modify the TFS build process template via adding BuildDetail.Status = BuildStatus.Failed
activity when the script failed.
Please check this link for the details:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/aacc32f1-bc29-4a85-bff3-4be1a43542e6/build-continues-after-prebuild-script-fails?forum=tfsbuild
And if you want to insert some error or warning message on the TFS build summary page, you needs to modify the TFS build process template as well. Please check:
http://blogs.msdn.com/b/buckh/archive/2012/06/07/how-to-customize-the-build-summary-page-in-tfs-2012-without-a-plug-in.aspx
Thanks.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
How to Reset dbid from a Shell Script
I would like to use a shell script to:
1) Automate the restore of our Produciton backups to a different server
2) Reset the dbid prior to exiting the script
Is there a way to reset the dbid from a shell script?
When I use the following, it has an interactive prompt in the middle of it, and I don't see anything in the syntax diagram found in the "Oracle Database Utilities" manual that will let me get around this.
nid target =/
DBNEWID: Release 10.2.0.3.0 - Production on Fri Aug 8 09:37:04 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to database DRTEST (DBID=3725550444)
Connected to server version 10.2.0
Control Files in database:
/s01/oradata/drtest/control01.ctl
/s01/oradata/drtest/control02.ctl
/u01/oradata/drtest/control03.ctl
Change database ID of database DRTEST? (Y/[N]) => y
Proceeding with operation
Changing database ID from 3725550444 to 3752603328
Control File /s01/oradata/drtest/control01.ctl - modified
Control File /s01/oradata/drtest/control02.ctl - modified
Control File /u01/oradata/drtest/control03.ctl - modified
Datafile /s01/oradata/drtest/system01.dbf - dbid changed
Datafile /s01/oradata/drtest/undotbs01.dbf - dbid changed
Datafile /s01/oradata/drtest/sysaux01.dbf - dbid changed
Datafile /s01/oradata/drtest/users01.dbf - dbid changed
Datafile /s01/oradata/drtest/rman.dbf - dbid changed
Datafile /s01/oradata/drtest/temp01.dbf - dbid changed
Control File /s01/oradata/drtest/control01.ctl - dbid changed
Control File /s01/oradata/drtest/control02.ctl - dbid changed
Control File /u01/oradata/drtest/control03.ctl - dbid changed
Instance shut down
Database ID for database DRTEST changed to 3752603328.
All previous backups and archived redo logs for this database are unusable.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database ID.
DBNEWID - Completed succesfully.... When I use the following, it has an interactive
prompt in the middle of it, ...You may want to try out "Expect" for automating any interactive script.
isotope -
How to retrive ip address of connected device in shell script or applescript
Hi all,
From Mac PC, how to get ip address of connected device in shell script or applescript.
there is any way to launch an app on ipad in shell script or applescript.
thank you in advance for your help
MickaelHi all,
From Mac PC, how to get ip address of connected device in shell script or applescript.
there is any way to launch an app on ipad in shell script or applescript.
thank you in advance for your help
Mickael -
Passing Multiple Parameters to SQL Script from a Shell Script
Hi Friends,
I have SQL script which accepts 6 parameters.
I am calling this from a shell script as shown below:
sqlplus -s ${ORACLE_ID} @${SQLPATH}KORONT_041.sql ${USER_ID} ${PDC} ${item_number} ${KORDC} ${PDCSET} ${last_Updated_in_hours} Out of the six parameters, item_number is not a mandatory parameter.
When i pass all six parameters, there is no issue.
But when i leave item_number blank, i am getting the below error
Enter value for 6:
User requested Interrupt or EOF detected.Based on the error, it seems that the NULL values for item_number is ignored and SQL*PLUS is waiting for one more input from user.
How can i overcome this issue?
Regards,
SreekanthHi,
I am calling the shell script from concurrent program and below is the log file of the concurrent program.
Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
KORONT_041_SH module: KORONT - Daily Item Master Update
+---------------------------------------------------------------------------+
Current system time is 29-JUN-2011 10:09:35
+---------------------------------------------------------------------------+
REQUEST_ID: 68510795
USER_ID: 4219
PDC: 85
Item Number:
KORDC: 124
PDCSET: 1100000003
last_updated_in_hours: 24
EMAIL_ID: [email protected],[email protected]
SQLPATH: /e381/oracle/asodev01appl/custom/motont/1.0.0/sql/
RPTDIR: /e381/oracle/asodev01comn/admin/out/ASODEV01_asoprdb2
RPTFILE: o68510795.out
Table truncated.
*Enter value for 6: User requested Interrupt or EOF detected.*
Table truncated.
old 15: AND ic.organization_id = &&4
new 15: AND ic.organization_id = 1100000003
0 rows created.
Input truncated to 9 characters
old 8: AND organization_id = &&4
new 8: AND organization_id = 1100000003
0 rows created.
End of SQL
No record.
+---------------------------------------------------------------------------+
Executing request completion options...
+------------- 1) PRINT -------------+
Printing output file.
Request ID : 68510795
Number of copies : 0
Printer : noprint
+--------------------------------------+
Finished executing request completion options.
+---------------------------------------------------------------------------+
Concurrent request completed successfully
Current system time is 29-JUN-2011 10:09:38
+---------------------------------------------------------------------------+Regards,
Sreekanth -
Is it possible to pass a variable from a shell script back to an Automator action?
Is it possible to pass a variable from a shell script back to an Automator action?
For instance, if I assign a value of foo to $var1 in my shell script how would I retrieve/pass that value in the next Automator action. I see that there is a variable called "Shell Script" but I can't any information on how to use it.red_menace,
Thanks but I still don't understand how to pass a single value that was set in the UNIX scipt back to Automator has a variable. Take the example below, I write 4 varables to STDOUT and all 4 are stored in a variable named "storage". How do I assign 1 of these values to the Automator "storage" variable? For instance if I wanted to assign the value of $var2 to "storage" , how would I do that? -
Starting tomcat from a shell script
Hello-
I want to start Tomcat from a shell script that is called by an application on a web page. Problem is, the app that calls the script runs as user nobody.
I'm a permissions noob, so any suggestions as to how I could get this working are appreciated.
WillTomcat should be running if you intend to use it as a service.
You don't want people to be able to start (or.. stop !) services on your server from a web page... That would present a gaping security hole. -
Calling a report from unix shell script
Hi,
I had to call a report from unix shell script.
May i know the procedure to accomplish this
Thanks in Advance
A.GopalFirst you should not include the whole path to your report in the call ...
Use like this:
/ora/u01/oracle/v101/as2/bin/rwrun.sh report=an_stati destype=file desname=/ora/u01/oracle/v101/as2/test.pdf desformat=pdf
In $ORACLE_HOME/bin/reports.sh:
1) Verify that you have updated the REPORTS_PATH variable to include your folder where you have the report in question
REPORTS_PATH=/ora/u20/app/qits/env1/run:$ORACLE_HOME/reports/templates:$ORACLE_HOME/reports/samples/demo: ....
2) Verify that the REPORTS_TMP variable is pointing to a valid location and that the oracle user has access to write on it.
After that, post the content of the tracefile located at $ORACLE_HOME/reports/logs/{in-process report server name folder}/rwserver.trc
If no file is present then it means that you need to enable trace in your reports's conf file.... go to the $ORACLE_HOME/reports/conf folder and and locate the .conf file that correspond to your in-process reports server name (as specified in the rwservelet.properties file)... open/edit the file to enable trace logs ..
i.e.
Change the following line:
<!--trace traceOpts="trace_all"/-->
to <trace traceOpts="trace_all"/>
Bounce the reports server and try to run the report again, this time the .trc file should be generated, post the content so that we can take a look. -
Calling stored procedure from unix shell script
Hello,
I am facing a problem while calling a stored procedure from UNIX shell script. I want to return a output variable from the stored procedure to the UNIX environment.
Here is the code-
#!/bin/sh
OUTPUT=`sqlplus cmag/magnum@dw <<ENDOFSQL
set serveroutput on;
var prd_out varchar2(100);
exec create_pm_window(:prd_out);
exit;
ENDOFSQL`
echo " output is - $OUTPUT"
The problem is :prd_out is not getting copied to shell variable OUTPUT.
I have a dbms_output.put_line in the stored proc create_pm_window and I can see that prd_out is getting populated.
Any help is really appreciated.
Thanks'
RakheeFirst step :
make sure the PL/SQL works as expected.
Does the following display the expected output executed from SQL*Plus ?
set serverout on
declare
prd_out varchar2(100);
begin
create_pm_window(prd_out);
dbms_output.put_line('output is '||prd_out);
end;
I don't have your procedure, but using a dummy procedure like :
Scott@my10g SQL>create procedure foo(p_out in out varchar2)
2 is
3 begin
4 select 'Hello '||instance_name into p_out from v$instance;
5 end;
6 /
Procedure created. and a toto.sh script as :OUTPUT=`sqlplus -s scott/tiger <<EOF
set pages 0 lines 120 trimout on trimspool on tab off echo off verify off feed off serverout on
var mavar varchar2(100);
exec foo(:mavar);
print mavar;
exit;
EOF`
echo "OUT = ${OUTPUT}"
exitIt works fine :[oracle@Nicosa-oel ~]$ ./toto.sh
OUT = Hello my10g -
Error when running the OWB process flow from the shell script
Hi,
I am able to deploy the process flow succesfully but when I execute the process flow from the shell script,I am getting the following error.Previously it worked fine.
I had to make some chnage in the IP address,so i had to deploy again.
Connected.
SQL> @/oracle/product/owb92028/owb/rtp/sql/oem_exec_template.sql OWB_RTR LOC_P_REL PROCESS P_W_SOURCE "," ","
Elapsed: 00:00:00.00
Elapsed: 00:00:00.01
Stage 1: Decoding Parameters
| location_name=LOC_P_REL
| task_type=ProcessFlow
| task_name=P_W_SOURCE
Stage 2: Opening Task
declare
ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "OWB_RTR.WB_RT_API_EXEC", line 17
ORA-06512: at "OWB_RTR.WB_RT_API_EXEC", line 137
ORA-06512: at "OWB_RTR.WB_RT_API_EXEC", line 164
ORA-06512: at line 205
Thanks in advance.
VinayHi Kamal and kanakam kolla,
This is just to let you know that,I solved my problem little differently by creating a new location and deployed the process flow.Now my process flow is working fine when i call from the shell script.What i see is that, it does not update properly when we update and redeploy the process flow.So far this is the work arround i could think off and i succesfully tested this.
Thank you Kamal and kanakam kolla,for giving a thought towards my problem.
Thanks
Vinay -
Return codes from sqlldr command from unix shell script
I am trying to capture error code from sql loader from unix shell script and display proper messages.
sqlldr parfile=sdb.par control=$cntlfile data=$infile bad=$badFile log=$logFile rows=10000
rows=10000
retcode=`echo $?`
case "$retcode" in
0) echo "SQL*Loader execution successful" ;;
1) echo "SQL*Loader execution exited with EX_FAIL, see logfile" ;;
2) echo "SQL*Loader execution exited with EX_WARN, see logfile" ;;
3) echo "SQL*Loader execution encountered a fatal error" ;;
*) echo "unknown return code";;
esac
Eventhough, there are errors while executing sqlldr, it is always returing recode zero. What could be the possible reason
Please adviceIs there a typo in your code ?
sqlldr parfile=sdb.par control=$cntlfile data=$infile bad=$badFile log=$logFile rows=10000
rows=10000
retcode=`echo $?` In this code, you get the return code of the statement in bold which is not the sqlldr statement ... -
Reading variables from a shell script
i was wondering if it is possible to enter variables from a shell script that an sql file can use:
ex:
shell script file
#!/bin/ksh
stty -echo
read pwd?"Enter password for user: "
echo
stty echo
read var?"Please enter value for variable: "
echo
$ORACLE_HOME/bin/sqlplus user/$pwd @TEST.sql
sql file TEST.sql
set serveroutput on
set verify off
spool out.log
update table set parameter_value = '$var' where parameter_name = 'X';
commit;
exit;
spool off;
i tried that and it seems its updating my table with "var" and not what the user entered that is the bind variable $var
am i missing something?if user hits enter (which means null) can the program
not end and ask the user to enter another value?Try this way :
while :
do
echo -n "Please enter value for variable: "
read VAR
if [ "$VAR" ]; then
break
else
continue
fi
done -
How do I use a dynamic variable from a prolog script?
I have my test broken in to three scripts, a login, an update, and a logout. There is a dynamic variable, SERVICE_VIRTUAL_CLIENT, from the login script that I need to use in the update script, but I can't figure out how to do it. Any help would be appreciated.
Edit: I forgot to mention that the login script is only run in the prolog portion of the UDP.
Scott
Message was edited by: scottmorganScott,
You would do this the same way you would in a stand-alone script. Create the variable pattern in the login in script and name the variable. Save the login script and open the other script and select the parameter where you need the value. Set the parameter value to {{variableNameFromLogin}} (Variables are transferred from one script to the next in a UDP).
I hope this makes sense
Maybe you are looking for
-
IPod Touch no longer syncing with iTunes?
Mac OS X v10.4.11 - all software up to date - iTunes 9.2.1 (5); no later updates available on this machine iPod Touch v3.1.3 This iPod Touch used to sync to iTunes just fine and dandy. Now it won't. I'm seeing that *now* in order to sync I have to up
-
Adding soap header in MX6.1
I have a code working on MX7, it first adds soap header(username and password) then gets the response, but similar code didn't work on MX6.1. Please help. MX7 code: <cfscript> ru = XmlNew(); ru.AuthenticationHeader = XmlElemNew(ru, " http://www.mytes
-
Hello everybody, Our project structures consist of WBS elements only -no networks-. I configured the WBS scheduling profile with "scheduling type = Forwards", and "Schedul. method = WBS determines dates". I configured the project profile with "sche
-
Adobe Support is a profound waste of time.
-
Table style alignment ignored?
TCS 2.0, linking FrameMaker 9 (unstructured) files to RH8. My FrameMaker files have several one-cell right-aligned tables. I mapped all the tables to a table style called "Product" in RoboHelp. The table properties in style mapping are set to be righ