Help with a simple bat file

A

Ayush

I want to make a script that can convert the alias that i enter in address
Toolbar to full URLs then open my browser with that URL.

I created a bat file named z.bat in a location that is in my path variable so
that i can enter the text as a parameter like this :
z myalias

Now i want the bat file to take the parameter and change that to full url and
then open my browser giving it the full url as a parameter. How to do it ?

The problems are :
1. If i do something like this :
"C:\program files\Mozilla firefox\firefox.exe" THECONVERTEDURL
It opens the browser and url but the command prompt window remain until i close
my browser. I don't want the window to remain. In fact, i don't even want a
splash of it.

2. I am thinking of using "if" command for converting aliases in urls. Is there
any better alternative. Best will be if it can read from a file and then convert
that accordingly. This way i can simply enter alias=URL to that database type
file.




If anyone can tell me a newsgroup or forum that is made for Batch file then it
will be better for me and everyone..
 
P

Pegasus \(MVP\)

See below.

Ayush said:
I want to make a script that can convert the alias that i enter in address
Toolbar to full URLs then open my browser with that URL.

I created a bat file named z.bat in a location that is in my path variable so
that i can enter the text as a parameter like this :
z myalias

Now i want the bat file to take the parameter and change that to full url and
then open my browser giving it the full url as a parameter. How to do it ?

The problems are :
1. If i do something like this :
"C:\program files\Mozilla firefox\firefox.exe" THECONVERTEDURL
It opens the browser and url but the command prompt window remain until i close
my browser. I don't want the window to remain. In fact, i don't even want a
splash of it.

Put this line into your batch file:

start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe"
THECONVERTEDURL
2. I am thinking of using "if" command for converting aliases in urls. Is there
any better alternative. Best will be if it can read from a file and then convert
that accordingly. This way i can simply enter alias=URL to that database type
file.

No problem reading a line from a text file:

for /f %%a in (c:\url.txt) do set url=%%a
start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe" www.%url%
 
A

Ayush

Replied To {REPLY BELOW} :
-------------------------------------------------------------

| See below.
|
| "Ayush" <ayushmaan.j[aatt]gmail.com> wrote in message
| | > I want to make a script that can convert the alias that i enter in address
| > Toolbar to full URLs then open my browser with that URL.
| >
| > I created a bat file named z.bat in a location that is in my path variable
| so
| > that i can enter the text as a parameter like this :
| > z myalias
| >
| > Now i want the bat file to take the parameter and change that to full url
| and
| > then open my browser giving it the full url as a parameter. How to do it ?
| >
| > The problems are :
| > 1. If i do something like this :
| > "C:\program files\Mozilla firefox\firefox.exe" THECONVERTEDURL
| > It opens the browser and url but the command prompt window remain until i
| close
| > my browser. I don't want the window to remain. In fact, i don't even want
| a
| > splash of it.
|
| Put this line into your batch file:
|
| start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe"
| THECONVERTEDURL

Worked as i expected. THANKS....


|
| > 2. I am thinking of using "if" command for converting aliases in urls. Is
| there
| > any better alternative. Best will be if it can read from a file and then
| convert
| > that accordingly. This way i can simply enter alias=URL to that database
| type
| > file.
|
| No problem reading a line from a text file:
|
| for /f %%a in (c:\url.txt) do set url=%%a
| start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe" www.%url%

I have lots of aliases and urls in a single text file. This script sets the
variable URL to the last line in the text file.
I have aliases and urls in this format :
alias<SPACE>URL

Example :
g3 http://kgiii.info/windows/XP.html
gamess http://www.dodge.com/games/
gcardd http://www.123greetings.com/
gl www.google.com
gla http://www.google.co.in/advanced_search?hl=en
goodiess http://www.filehungry.com/english/showcase/Windows_Software
grantr http://www.us.playstation.com/Content/OGS/SCUS-97328/Site/
greatts http://3d2f.com/programs/1-131-totalsize-download.shtml
helperr
http://www.theglobeandmail.com/serv...ktoptrouble/BNStory/Technology/Troubleshooter
helplinee http://blogs.chron.com/helpline/
hlpn http://www.microsoft.com/wn3/locales/help/help_en-us.htm
inline
http://www.softpedia.com/get/Authoring-tools/Setup-creators/Nullsoft-Installation-System.shtml
jok http://www.jokefile.co.uk
jokeess http://ixpats.com/bestoftheweb/
mmm http://www.actualtools.com/products/index.php#aim
movy http://www.adlabscinemas.com/
ms http://www.microsoft.com/
msq http://search.microsoft.com/results.aspx?mkt=en-US&setlang=en-US&q=query

AND Can you tell me what actually the for loop is doing ? I try to know from for
/? but cant get it.
 
P

Pegasus \(MVP\)

Ayush said:
Replied To {REPLY BELOW} :
-------------------------------------------------------------

| See below.
|
| "Ayush" <ayushmaan.j[aatt]gmail.com> wrote in message
| | > I want to make a script that can convert the alias that i enter in address
| > Toolbar to full URLs then open my browser with that URL.
| >
| > I created a bat file named z.bat in a location that is in my path variable
| so
| > that i can enter the text as a parameter like this :
| > z myalias
| >
| > Now i want the bat file to take the parameter and change that to full url
| and
| > then open my browser giving it the full url as a parameter. How to do it ?
| >
| > The problems are :
| > 1. If i do something like this :
| > "C:\program files\Mozilla firefox\firefox.exe" THECONVERTEDURL
| > It opens the browser and url but the command prompt window remain until i
| close
| > my browser. I don't want the window to remain. In fact, i don't even want
| a
| > splash of it.
|
| Put this line into your batch file:
|
| start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe"
| THECONVERTEDURL

Worked as i expected. THANKS....


|
| > 2. I am thinking of using "if" command for converting aliases in urls. Is
| there
| > any better alternative. Best will be if it can read from a file and then
| convert
| > that accordingly. This way i can simply enter alias=URL to that database
| type
| > file.
|
| No problem reading a line from a text file:
|
| for /f %%a in (c:\url.txt) do set url=%%a
| start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe" www.%url%

I have lots of aliases and urls in a single text file. This script sets the
variable URL to the last line in the text file.
I have aliases and urls in this format :
alias<SPACE>URL

Example :
g3 http://kgiii.info/windows/XP.html
gamess http://www.dodge.com/games/
gcardd http://www.123greetings.com/
gl www.google.com
gla http://www.google.co.in/advanced_search?hl=en
goodiess http://www.filehungry.com/english/showcase/Windows_Software
grantr http://www.us.playstation.com/Content/OGS/SCUS-97328/Site/
greatts http://3d2f.com/programs/1-131-totalsize-download.shtml
helperr
http://www.theglobeandmail.com/serv...ktoptrouble/BNStory/Technology/Troubleshooter
helplinee http://blogs.chron.com/helpline/
hlpn http://www.microsoft.com/wn3/locales/help/help_en-us.htm
inline
http://www.softpedia.com/get/Authoring-tools/Setup-creators/Nullsoft-Installation-System.shtml
jok http://www.jokefile.co.uk
jokeess http://ixpats.com/bestoftheweb/
mmm http://www.actualtools.com/products/index.php#aim
movy http://www.adlabscinemas.com/
ms http://www.microsoft.com/
msq http://search.microsoft.com/results.aspx?mkt=en-US&setlang=en-US&q=query

AND Can you tell me what actually the for loop is doing ? I try to know from for
/? but cant get it.

To avoid guessing games, it is best to do this ***before*** posting:
1. Think about your exact requirements (or the nature of the problem).
2. Put it all into the post.

In your case I ***guess*** that this is what you wish to do do:
1. Prompt the user for a keyword, e.g. "jokes".
2. Scan a list of URLs for this keyword.
3. Extract the appropriate line from the list.
4. Launch the selected web page.

So far you have alluded to this type of action but you
never actually spelt it out. Is this what you require?

About your second question: The "for" command is
not only used for loops but also for lots of other things,
expecially when used with the /F switch. Type for /?
at the command prompt to get a rough idea. It takes a
lot of experience and practice to use this command to its
full extent.
 
D

dev

/Ayush/ said:
I want to make a script that can convert the alias that i enter in address
Toolbar to full URLs then open my browser with that URL.

I created a bat file named z.bat in a location that is in my path variable so
that i can enter the text as a parameter like this :
z myalias

Now i want the bat file to take the parameter and change that to full url and
then open my browser giving it the full url as a parameter. How to do it ?

The problems are :
1. If i do something like this :
"C:\program files\Mozilla firefox\firefox.exe" THECONVERTEDURL
It opens the browser and url but the command prompt window remain until i close
my browser. I don't want the window to remain. In fact, i don't even want a
splash of it.

2. I am thinking of using "if" command for converting aliases in urls. Is there
any better alternative. Best will be if it can read from a file and then convert
that accordingly. This way i can simply enter alias=URL to that database type
file.

If anyone can tell me a newsgroup or forum that is made for Batch file then it
will be better for me and everyone..

Sounds as if you want the Internet Keyword feature built into the
SeaMonkey (and other Mozilla-based) browsers. It is done via bookmarks,
which are all kept in a single file (not like I.E. Favorites)...

I type in "ba" into the "location" bar, for example, and get the URL
that I have associated with that Keyword. Check out...
http://www.mozilla.org/docs/end-user/internet-keywords.html

for more uses of that feature.
 
P

Pennywise

dev said:
/Ayush/ said:


Sounds as if you want the Internet Keyword feature built into the
SeaMonkey (and other Mozilla-based) browsers. It is done via bookmarks,
which are all kept in a single file (not like I.E. Favorites)...

I type in "ba" into the "location" bar, for example, and get the URL
that I have associated with that Keyword. Check out...
http://www.mozilla.org/docs/end-user/internet-keywords.html

for more uses of that feature.

Opera does this as well
LOL takes me to http://www.acronymfinder.com/
and so on.
 
A

Ayush

Replied To :
-------------------------------------------------------------

I am thinking of using "if" command for converting aliases in urls.

| > | No problem reading a line from a text file:
| > |
| > | for /f %%a in (c:\url.txt) do set url=%%a
| > | start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe"
| www.%url%
| >
| > I have lots of aliases and urls in a single text file. This script sets
| the
| > variable URL to the last line in the text file.
| > I have aliases and urls in this format :
| > alias<SPACE>URL

| >
|
http://www.softpedia.com/get/Authoring-tools/Setup-creators/Nullsoft-Installation-System.shtml
| > jok http://www.jokefile.co.uk
| > AND Can you tell me what actually the for loop is doing ? I try to know
| from for
| > /? but cant get it.
| > --
| > Ayush [ Be ''?'' Happy ]
| >
| >
|
| To avoid guessing games, it is best to do this ***before*** posting:
| 1. Think about your exact requirements (or the nature of the problem).
| 2. Put it all into the post.
|


Sorry about that, i think that was not needed.




| In your case I ***guess*** that this is what you wish to do do:
| 1. Prompt the user for a keyword, e.g. "jokes".
| 2. Scan a list of URLs for this keyword.
| 3. Extract the appropriate line from the list.
| 4. Launch the selected web page.
| So far you have alluded to this type of action but you
| never actually spelt it out. Is this what you require?

First, i don't know how to do the above and don't want to do.
I want to take the parameter > then search for that in the text file > If found
then open the browser by giving the URL for the alias.
Now the main question is : Can this be done from script ? I mean : find the text
 
A

Ayush

Replied To :
-------------------------------------------------------------
| Sounds as if you want the Internet Keyword feature built into the
| SeaMonkey (and other Mozilla-based) browsers. It is done via bookmarks,
| which are all kept in a single file (not like I.E. Favorites)...
|
| I type in "ba" into the "location" bar, for example, and get the URL
| that I have associated with that Keyword. Check out...
| http://www.mozilla.org/docs/end-user/internet-keywords.html
|
| for more uses of that feature.


I don't think that page can tell you how to make my own aliases. BUT That gave
me an idea !! I remember the option keyword.URL in config of Firefox. I will
change that to a local html file that i am going to make by using Javascript
that will do the work.
 
A

Ayush

Replied To :
-------------------------------------------------------------
| Sounds as if you want the Internet Keyword feature built into the
| SeaMonkey (and other Mozilla-based) browsers. It is done via bookmarks,
| which are all kept in a single file (not like I.E. Favorites)...
|
| I type in "ba" into the "location" bar, for example, and get the URL
| that I have associated with that Keyword. Check out...
| http://www.mozilla.org/docs/end-user/internet-keywords.html
|
| for more uses of that feature.


I don't think that page can tell you how to make my own aliases. BUT That gave
me an idea !! I remember the option keyword.URL in config of Firefox. I will
change that to a local html file that i am going to make by using Javascript
that will do the work.
 
A

Ayush

Replied To :
-------------------------------------------------------------
| Sounds as if you want the Internet Keyword feature built into the
| SeaMonkey (and other Mozilla-based) browsers. It is done via bookmarks,
| which are all kept in a single file (not like I.E. Favorites)...
|
| I type in "ba" into the "location" bar, for example, and get the URL
| that I have associated with that Keyword. Check out...
| http://www.mozilla.org/docs/end-user/internet-keywords.html
|
| for more uses of that feature.


I don't think that page can tell you how to make my own aliases. BUT That gave
me an idea !! I remember the option keyword.URL in config of Firefox. I will
change that to a local html file that i am going to make by using Javascript
that will do the work.
 
P

Pegasus \(MVP\)

Ayush said:
Replied To :
-------------------------------------------------------------

I am thinking of using "if" command for converting aliases in urls.

| > | No problem reading a line from a text file:
| > |
| > | for /f %%a in (c:\url.txt) do set url=%%a
| > | start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe"
| www.%url%
| >
| > I have lots of aliases and urls in a single text file. This script sets
| the
| > variable URL to the last line in the text file.
| > I have aliases and urls in this format :
| > alias<SPACE>URL

| >
|
http://www.softpedia.com/get/Authoring-tools/Setup-creators/Nullsoft-Installation-System.shtml
| > jok http://www.jokefile.co.uk
| > AND Can you tell me what actually the for loop is doing ? I try to know
| from for
| > /? but cant get it.
| > --
| > Ayush [ Be ''?'' Happy ]
| >
| >
|
| To avoid guessing games, it is best to do this ***before*** posting:
| 1. Think about your exact requirements (or the nature of the problem).
| 2. Put it all into the post.
|


Sorry about that, i think that was not needed.




| In your case I ***guess*** that this is what you wish to do do:
| 1. Prompt the user for a keyword, e.g. "jokes".
| 2. Scan a list of URLs for this keyword.
| 3. Extract the appropriate line from the list.
| 4. Launch the selected web page.
| So far you have alluded to this type of action but you
| never actually spelt it out. Is this what you require?

First, i don't know how to do the above and don't want to do.
I want to take the parameter > then search for that in the text file > If found
then open the browser by giving the URL for the alias.
Now the main question is : Can this be done from script ? I mean : find the text
then retrieve the url after the text and space and before the new line.

Where does the parameter come from? In the absence of detailed
information, here is the raw batch file. It's just two lines long. Don't
add or omit any single or double quotes or other special characters
unless you know exactly what you're doing.

@echo off
for /F "tokens=2" %%a in ('type url.txt ^| find /i "SomeParameter"') do
start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe" "%%a"
 
A

Ayush

Replied To :
-------------------------------------------------------------

|
| "Ayush" <ayushmaan.j[aatt]gmail.com> wrote in message
| | >
| >
| > Replied To :
| > -------------------------------------------------------------
| >
| > | > I am thinking of using "if" command for converting aliases in urls.
| >
| > | > | No problem reading a line from a text file:
| > | > |
| > | > | for /f %%a in (c:\url.txt) do set url=%%a
| > | > | start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe"
| > | www.%url%
| > | >
| > | > I have lots of aliases and urls in a single text file. This script
| sets
| > | the
| > | > variable URL to the last line in the text file.
| > | > I have aliases and urls in this format :
| > | > alias<SPACE>URL
| >
| > | >
| > |
| >
|
http://www.softpedia.com/get/Authoring-tools/Setup-creators/Nullsoft-Installation-System.shtml
| > | > jok http://www.jokefile.co.uk
| > | > AND Can you tell me what actually the for loop is doing ? I try to
| know
| > | from for
| > | > /? but cant get it.
| > | > --
| > | > Ayush [ Be ''?'' Happy ]
| > | >
| > | >
| > |
| > | To avoid guessing games, it is best to do this ***before*** posting:
| > | 1. Think about your exact requirements (or the nature of the problem).
| > | 2. Put it all into the post.
| > |
| >
| >
| > Sorry about that, i think that was not needed.
| >
| >
| >
| >
| > | In your case I ***guess*** that this is what you wish to do do:
| > | 1. Prompt the user for a keyword, e.g. "jokes".
| > | 2. Scan a list of URLs for this keyword.
| > | 3. Extract the appropriate line from the list.
| > | 4. Launch the selected web page.
| > | So far you have alluded to this type of action but you
| > | never actually spelt it out. Is this what you require?
| >
| > First, i don't know how to do the above and don't want to do.
| > I want to take the parameter > then search for that in the text file > If
| found
| > then open the browser by giving the URL for the alias.
| > Now the main question is : Can this be done from script ? I mean : find
| the text
| > > then retrieve the url after the text and space and before the new line.
| >
| > --
| > Ayush [ Be ''?'' Happy ]
| >
| >
|
| Where does the parameter come from? In the absence of detailed
| information, here is the raw batch file. It's just two lines long. Don't
| add or omit any single or double quotes or other special characters
| unless you know exactly what you're doing.

The parameter will come from the address toolbar. I will type like this :
z <alias as a parameter>


|
| @echo off
| for /F "tokens=2" %%a in ('type url.txt ^| find /i "SomeParameter"') do
| start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe" "%%a"

That script just flashes for a second. I placed a the file in the directory
where this script is located and renamed it to url.txt but the script just
flashes away. I changed the SomeParameter to a text that is in the text file but
it just flashes away. It doesn't even open FireFox.
 
P

Pegasus \(MVP\)

Ayush said:
Replied To :
-------------------------------------------------------------

|
| "Ayush" <ayushmaan.j[aatt]gmail.com> wrote in message
| | >
| >
| > Replied To :
| > -------------------------------------------------------------
| >
| > | > I am thinking of using "if" command for converting aliases in urls.
| >
| > | > | No problem reading a line from a text file:
| > | > |
| > | > | for /f %%a in (c:\url.txt) do set url=%%a
| > | > | start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe"
| > | www.%url%
| > | >
| > | > I have lots of aliases and urls in a single text file. This script
| sets
| > | the
| > | > variable URL to the last line in the text file.
| > | > I have aliases and urls in this format :
| > | > alias<SPACE>URL
| >
| > | >
| > |
| >
|
http://www.softpedia.com/get/Authoring-tools/Setup-creators/Nullsoft-Installation-System.shtml
| > | > jok http://www.jokefile.co.uk
| > | > AND Can you tell me what actually the for loop is doing ? I try to
| know
| > | from for
| > | > /? but cant get it.
| > | > --
| > | > Ayush [ Be ''?'' Happy ]
| > | >
| > | >
| > |
| > | To avoid guessing games, it is best to do this ***before*** posting:
| > | 1. Think about your exact requirements (or the nature of the problem).
| > | 2. Put it all into the post.
| > |
| >
| >
| > Sorry about that, i think that was not needed.
| >
| >
| >
| >
| > | In your case I ***guess*** that this is what you wish to do do:
| > | 1. Prompt the user for a keyword, e.g. "jokes".
| > | 2. Scan a list of URLs for this keyword.
| > | 3. Extract the appropriate line from the list.
| > | 4. Launch the selected web page.
| > | So far you have alluded to this type of action but you
| > | never actually spelt it out. Is this what you require?
| >
| > First, i don't know how to do the above and don't want to do.
| > I want to take the parameter > then search for that in the text file > If
| found
| > then open the browser by giving the URL for the alias.
| > Now the main question is : Can this be done from script ? I mean : find
| the text
| > > then retrieve the url after the text and space and before the new line.
| >
| > --
| > Ayush [ Be ''?'' Happy ]
| >
| >
|
| Where does the parameter come from? In the absence of detailed
| information, here is the raw batch file. It's just two lines long. Don't
| add or omit any single or double quotes or other special characters
| unless you know exactly what you're doing.

The parameter will come from the address toolbar. I will type like this :
z <alias as a parameter>


|
| @echo off
| for /F "tokens=2" %%a in ('type url.txt ^| find /i "SomeParameter"') do
| start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe" "%%a"

That script just flashes for a second. I placed a the file in the directory
where this script is located and renamed it to url.txt but the script just
flashes away. I changed the SomeParameter to a text that is in the text file but
it just flashes away. It doesn't even open FireFox.

1. Paste these two lines into c:\test.bat:
@echo off
for /F "tokens=2" %%a in ('type c:\url.txt ^| find /i "%1"') do start /b
"FireFox" "C:\program files\Mozilla firefox\firefox.exe" "%%a"


2. Paste the following lines into c:\url.txt:
g3 http://kgiii.info/windows/XP.html
gamess http://www.dodge.com/games/
gcardd http://www.123greetings.com/
gl www.google.com
gla http://www.google.co.in/advanced_search?hl=en
goodiess http://www.filehungry.com/english/showcase/Windows_Software
grantr http://www.us.playstation.com/Content/OGS/SCUS-97328/Site/
greatts http://3d2f.com/programs/1-131-totalsize-download.shtml
helperr
http://www.theglobeandmail.com/serv...ktoptrouble/BNStory/Technology/Troubleshooter
helplinee http://blogs.chron.com/helpline/
hlpn http://www.microsoft.com/wn3/locales/help/help_en-us.htm
inline
http://www.softpedia.com/get/Authoring-tools/Setup-creators/Nullsoft-Installation-System.shtml
jok http://www.jokefile.co.uk
jokeess http://ixpats.com/bestoftheweb/
mmm http://www.actualtools.com/products/index.php#aim
movy http://www.adlabscinemas.com/
ms http://www.microsoft.com/
msq http://search.microsoft.com/results.aspx?mkt=en-US&setlang=en-US&q=query

3. Start a Command Prompt.

4. Type this command:
c:\test.bat jokeess

You will now see that the batch file works very well. Since you
were reluctant to fully define your project when I suggested you
should, I will leave it up to you to interface it with whatever you
wish to interface it with.

Have a look at your original question, then gauge for yourself
how little your current requirements have in common with that
initial question. This is why I asked for a well-thought out
specification - which is the first step in any programming effort!
 
E

Edwin vMierlo

that batch file works like a charm


;-)





Pegasus (MVP) said:
Ayush said:
Replied To :
-------------------------------------------------------------

|
| "Ayush" <ayushmaan.j[aatt]gmail.com> wrote in message
| | >
| >
| > Replied To :
| > -------------------------------------------------------------
| >
| > | > I am thinking of using "if" command for converting aliases in urls.
| >
| > | > | No problem reading a line from a text file:
| > | > |
| > | > | for /f %%a in (c:\url.txt) do set url=%%a
| > | > | start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe"
| > | www.%url%
| > | >
| > | > I have lots of aliases and urls in a single text file. This script
| sets
| > | the
| > | > variable URL to the last line in the text file.
| > | > I have aliases and urls in this format :
| > | > alias<SPACE>URL
| >
| > | >
| > |
| >
|
http://www.softpedia.com/get/Authoring-tools/Setup-creators/Nullsoft-Installation-System.shtml
| > | > jok http://www.jokefile.co.uk
| > | > AND Can you tell me what actually the for loop is doing ? I try to
| know
| > | from for
| > | > /? but cant get it.
| > | > --
| > | > Ayush [ Be ''?'' Happy ]
| > | >
| > | >
| > |
| > | To avoid guessing games, it is best to do this ***before*** posting:
| > | 1. Think about your exact requirements (or the nature of the problem).
| > | 2. Put it all into the post.
| > |
| >
| >
| > Sorry about that, i think that was not needed.
| >
| >
| >
| >
| > | In your case I ***guess*** that this is what you wish to do do:
| > | 1. Prompt the user for a keyword, e.g. "jokes".
| > | 2. Scan a list of URLs for this keyword.
| > | 3. Extract the appropriate line from the list.
| > | 4. Launch the selected web page.
| > | So far you have alluded to this type of action but you
| > | never actually spelt it out. Is this what you require?
| >
| > First, i don't know how to do the above and don't want to do.
| > I want to take the parameter > then search for that in the text file
If
| found
| > then open the browser by giving the URL for the alias.
| > Now the main question is : Can this be done from script ? I mean : find
| the text
| > > then retrieve the url after the text and space and before the new line.
| >
| > --
| > Ayush [ Be ''?'' Happy ]
| >
| >
|
| Where does the parameter come from? In the absence of detailed
| information, here is the raw batch file. It's just two lines long. Don't
| add or omit any single or double quotes or other special characters
| unless you know exactly what you're doing.

The parameter will come from the address toolbar. I will type like this :
z <alias as a parameter>


|
| @echo off
| for /F "tokens=2" %%a in ('type url.txt ^| find /i "SomeParameter"') do
| start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe" "%%a"

That script just flashes for a second. I placed a the file in the directory
where this script is located and renamed it to url.txt but the script just
flashes away. I changed the SomeParameter to a text that is in the text file but
it just flashes away. It doesn't even open FireFox.

1. Paste these two lines into c:\test.bat:
@echo off
for /F "tokens=2" %%a in ('type c:\url.txt ^| find /i "%1"') do start /b
"FireFox" "C:\program files\Mozilla firefox\firefox.exe" "%%a"


2. Paste the following lines into c:\url.txt:
g3 http://kgiii.info/windows/XP.html
gamess http://www.dodge.com/games/
gcardd http://www.123greetings.com/
gl www.google.com
gla http://www.google.co.in/advanced_search?hl=en
goodiess http://www.filehungry.com/english/showcase/Windows_Software
grantr http://www.us.playstation.com/Content/OGS/SCUS-97328/Site/
greatts http://3d2f.com/programs/1-131-totalsize-download.shtml
helperr
http://www.theglobeandmail.com/serv...ktoptrouble/BNStory/Technology/Troubleshooter
helplinee http://blogs.chron.com/helpline/
hlpn http://www.microsoft.com/wn3/locales/help/help_en-us.htm
inline
http://www.softpedia.com/get/Authoring-tools/Setup-creators/Nullsoft-Installation-System.shtml
jok http://www.jokefile.co.uk
jokeess http://ixpats.com/bestoftheweb/
mmm http://www.actualtools.com/products/index.php#aim
movy http://www.adlabscinemas.com/
ms http://www.microsoft.com/
msq http://search.microsoft.com/results.aspx?mkt=en-US&setlang=en-US&q=query

3. Start a Command Prompt.

4. Type this command:
c:\test.bat jokeess

You will now see that the batch file works very well. Since you
were reluctant to fully define your project when I suggested you
should, I will leave it up to you to interface it with whatever you
wish to interface it with.

Have a look at your original question, then gauge for yourself
how little your current requirements have in common with that
initial question. This is why I asked for a well-thought out
specification - which is the first step in any programming effort!
 
A

Ayush

Thanks for your patience and support. That worked but still there is a bug in it
that whenever it founds the text (parameter), it opens that website. I tested
the alias "ms" and it opened every occurrence of ms. It opened these sites:
http://3d2f.com/programs/1-131-totalsize-download.shtml
*ms in programs
ms http://www.microsoft.com/
*ms in ms
msq http://search.microsoft.com/results.aspx?mkt=en-US&setlang=en-US&q=query
*ms in msq

Can you modified the script so that it will not open any ms that is not
separate.Example: programs.
--
Ayush [ Be ''?'' Happy ]

For any query, search - www.Google.com
Want to know about a term - http://en.wikipedia.org

Replied To :
-------------------------------------------------------------

|
| "Ayush" <ayushmaan.j[aatt]gmail.com> wrote in message
| | >
| >
| >
| > Replied To :
| > -------------------------------------------------------------
| >
| > | > |
| > | "Ayush" <ayushmaan.j[aatt]gmail.com> wrote in message
| > | | > | >
| > | >
| > | > Replied To :
| > | > -------------------------------------------------------------
| > | >
| > | > | > | > I am thinking of using "if" command for converting aliases in urls.
| > | >
| > | > | > | No problem reading a line from a text file:
| > | > | > |
| > | > | > | for /f %%a in (c:\url.txt) do set url=%%a
| > | > | > | start /b "FireFox" "C:\program files\Mozilla
| firefox\firefox.exe"
| > | > | www.%url%
| > | > | >
| > | > | > I have lots of aliases and urls in a single text file. This script
| > | sets
| > | > | the
| > | > | > variable URL to the last line in the text file.
| > | > | > I have aliases and urls in this format :
| > | > | > alias<SPACE>URL
| > | >
| > | > | >
| > | > |
| > | >
| > |
| >
|
http://www.softpedia.com/get/Authoring-tools/Setup-creators/Nullsoft-Installation-System.shtml
| > | > | > jok http://www.jokefile.co.uk
| > | > | > AND Can you tell me what actually the for loop is doing ? I try to
| > | know
| > | > | from for
| > | > | > /? but cant get it.
| > | > | > --
| > | > | > Ayush [ Be ''?'' Happy ]
| > | > | >
| > | > | >
| > | > |
| > | > | To avoid guessing games, it is best to do this ***before*** posting:
| > | > | 1. Think about your exact requirements (or the nature of the
| problem).
| > | > | 2. Put it all into the post.
| > | > |
| > | >
| > | >
| > | > Sorry about that, i think that was not needed.
| > | >
| > | >
| > | >
| > | >
| > | > | In your case I ***guess*** that this is what you wish to do do:
| > | > | 1. Prompt the user for a keyword, e.g. "jokes".
| > | > | 2. Scan a list of URLs for this keyword.
| > | > | 3. Extract the appropriate line from the list.
| > | > | 4. Launch the selected web page.
| > | > | So far you have alluded to this type of action but you
| > | > | never actually spelt it out. Is this what you require?
| > | >
| > | > First, i don't know how to do the above and don't want to do.
| > | > I want to take the parameter > then search for that in the text file >
| If
| > | found
| > | > then open the browser by giving the URL for the alias.
| > | > Now the main question is : Can this be done from script ? I mean :
| find
| > | the text
| > | > > then retrieve the url after the text and space and before the new
| line.
| > | >
| > | > --
| > | > Ayush [ Be ''?'' Happy ]
| > | >
| > | >
| > |
| > | Where does the parameter come from? In the absence of detailed
| > | information, here is the raw batch file. It's just two lines long. Don't
| > | add or omit any single or double quotes or other special characters
| > | unless you know exactly what you're doing.
| >
| > The parameter will come from the address toolbar. I will type like this :
| > z <alias as a parameter>
| >
| >
| > |
| > | @echo off
| > | for /F "tokens=2" %%a in ('type url.txt ^| find /i "SomeParameter"') do
| > | start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe" "%%a"
| >
| > That script just flashes for a second. I placed a the file in the
| directory
| > where this script is located and renamed it to url.txt but the script just
| > flashes away. I changed the SomeParameter to a text that is in the text
| file but
| > it just flashes away. It doesn't even open FireFox.
| >
| >
| >
| > --
| > Ayush [ Be ''?'' Happy ]
| >
| >
|
| 1. Paste these two lines into c:\test.bat:
| @echo off
| for /F "tokens=2" %%a in ('type c:\url.txt ^| find /i "%1"') do start /b
| "FireFox" "C:\program files\Mozilla firefox\firefox.exe" "%%a"
|
|
| 2. Paste the following lines into c:\url.txt:
| g3 http://kgiii.info/windows/XP.html
| gamess http://www.dodge.com/games/
| gcardd http://www.123greetings.com/
| gl www.google.com
| gla http://www.google.co.in/advanced_search?hl=en
| goodiess http://www.filehungry.com/english/showcase/Windows_Software
| grantr http://www.us.playstation.com/Content/OGS/SCUS-97328/Site/
| greatts http://3d2f.com/programs/1-131-totalsize-download.shtml
| helperr
|
http://www.theglobeandmail.com/serv...ktoptrouble/BNStory/Technology/Troubleshooter
| helplinee http://blogs.chron.com/helpline/
| hlpn http://www.microsoft.com/wn3/locales/help/help_en-us.htm
| inline
|
http://www.softpedia.com/get/Authoring-tools/Setup-creators/Nullsoft-Installation-System.shtml
| jok http://www.jokefile.co.uk
| jokeess http://ixpats.com/bestoftheweb/
| mmm http://www.actualtools.com/products/index.php#aim
| movy http://www.adlabscinemas.com/

|
| 3. Start a Command Prompt.
|
| 4. Type this command:
| c:\test.bat jokeess
|
| You will now see that the batch file works very well. Since you
| were reluctant to fully define your project when I suggested you
| should, I will leave it up to you to interface it with whatever you
| wish to interface it with.
|
| Have a look at your original question, then gauge for yourself
| how little your current requirements have in common with that
| initial question. This is why I asked for a well-thought out
| specification - which is the first step in any programming effort!
|
|
 
P

Pegasus \(MVP\)

This is not a "bug" as you like to call it but is the direct result
of your lack of functional specification that I keep mentioning.
It's often called "scope creep".

You're a programmer. Use a further "find" pipe to suppress
lines that include the string "*ms"! (if that's what you want,
which I'm not sure at all).



Ayush said:
Thanks for your patience and support. That worked but still there is a bug in it
that whenever it founds the text (parameter), it opens that website. I tested
the alias "ms" and it opened every occurrence of ms. It opened these sites:
http://3d2f.com/programs/1-131-totalsize-download.shtml
*ms in programs
ms http://www.microsoft.com/
*ms in ms
msq http://search.microsoft.com/results.aspx?mkt=en-US&setlang=en-US&q=query
*ms in msq

Can you modified the script so that it will not open any ms that is not
separate.Example: programs.
--
Ayush [ Be ''?'' Happy ]

For any query, search - www.Google.com
Want to know about a term - http://en.wikipedia.org

Replied To :
-------------------------------------------------------------

|
| "Ayush" <ayushmaan.j[aatt]gmail.com> wrote in message
| | >
| >
| >
| > Replied To :
| > -------------------------------------------------------------
| >
| > | > |
| > | "Ayush" <ayushmaan.j[aatt]gmail.com> wrote in message
| > | | > | >
| > | >
| > | > Replied To :
| > | > -------------------------------------------------------------
| > | >
| > | > | > | > I am thinking of using "if" command for converting aliases in urls.
| > | >
| > | > | > | No problem reading a line from a text file:
| > | > | > |
| > | > | > | for /f %%a in (c:\url.txt) do set url=%%a
| > | > | > | start /b "FireFox" "C:\program files\Mozilla
| firefox\firefox.exe"
| > | > | www.%url%
| > | > | >
| > | > | > I have lots of aliases and urls in a single text file. This script
| > | sets
| > | > | the
| > | > | > variable URL to the last line in the text file.
| > | > | > I have aliases and urls in this format :
| > | > | > alias<SPACE>URL
| > | >
| > | > | >
| > | > |
| > | >
| > |
| >
|
http://www.softpedia.com/get/Authoring-tools/Setup-creators/Nullsoft-Installation-System.shtml
| > | > | > jok http://www.jokefile.co.uk
| > | > | > AND Can you tell me what actually the for loop is doing ? I try to
| > | know
| > | > | from for
| > | > | > /? but cant get it.
| > | > | > --
| > | > | > Ayush [ Be ''?'' Happy ]
| > | > | >
| > | > | >
| > | > |
| > | > | To avoid guessing games, it is best to do this ***before*** posting:
| > | > | 1. Think about your exact requirements (or the nature of the
| problem).
| > | > | 2. Put it all into the post.
| > | > |
| > | >
| > | >
| > | > Sorry about that, i think that was not needed.
| > | >
| > | >
| > | >
| > | >
| > | > | In your case I ***guess*** that this is what you wish to do do:
| > | > | 1. Prompt the user for a keyword, e.g. "jokes".
| > | > | 2. Scan a list of URLs for this keyword.
| > | > | 3. Extract the appropriate line from the list.
| > | > | 4. Launch the selected web page.
| > | > | So far you have alluded to this type of action but you
| > | > | never actually spelt it out. Is this what you require?
| > | >
| > | > First, i don't know how to do the above and don't want to do.
| > | > I want to take the parameter > then search for that in the text file >
| If
| > | found
| > | > then open the browser by giving the URL for the alias.
| > | > Now the main question is : Can this be done from script ? I mean :
| find
| > | the text
| > | > > then retrieve the url after the text and space and before the new
| line.
| > | >
| > | > --
| > | > Ayush [ Be ''?'' Happy ]
| > | >
| > | >
| > |
| > | Where does the parameter come from? In the absence of detailed
| > | information, here is the raw batch file. It's just two lines long. Don't
| > | add or omit any single or double quotes or other special characters
| > | unless you know exactly what you're doing.
| >
| > The parameter will come from the address toolbar. I will type like this :
| > z <alias as a parameter>
| >
| >
| > |
| > | @echo off
| > | for /F "tokens=2" %%a in ('type url.txt ^| find /i "SomeParameter"') do
| > | start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe" "%%a"
| >
| > That script just flashes for a second. I placed a the file in the
| directory
| > where this script is located and renamed it to url.txt but the script just
| > flashes away. I changed the SomeParameter to a text that is in the text
| file but
| > it just flashes away. It doesn't even open FireFox.
| >
| >
| >
| > --
| > Ayush [ Be ''?'' Happy ]
| >
| >
|
| 1. Paste these two lines into c:\test.bat:
| @echo off
| for /F "tokens=2" %%a in ('type c:\url.txt ^| find /i "%1"') do start /b
| "FireFox" "C:\program files\Mozilla firefox\firefox.exe" "%%a"
|
|
| 2. Paste the following lines into c:\url.txt:
| g3 http://kgiii.info/windows/XP.html
| gamess http://www.dodge.com/games/
| gcardd http://www.123greetings.com/
| gl www.google.com
| gla http://www.google.co.in/advanced_search?hl=en
| goodiess http://www.filehungry.com/english/showcase/Windows_Software
| grantr http://www.us.playstation.com/Content/OGS/SCUS-97328/Site/
| greatts http://3d2f.com/programs/1-131-totalsize-download.shtml
| helperr
|
http://www.theglobeandmail.com/serv...ktoptrouble/BNStory/Technology/Troubleshooter
| helplinee http://blogs.chron.com/helpline/
| hlpn http://www.microsoft.com/wn3/locales/help/help_en-us.htm
| inline
|
http://www.softpedia.com/get/Authoring-tools/Setup-creators/Nullsoft-Installation-System.shtml
| jok http://www.jokefile.co.uk
| jokeess http://ixpats.com/bestoftheweb/
| mmm http://www.actualtools.com/products/index.php#aim
| movy http://www.adlabscinemas.com/

|
| 3. Start a Command Prompt.
|
| 4. Type this command:
| c:\test.bat jokeess
|
| You will now see that the batch file works very well. Since you
| were reluctant to fully define your project when I suggested you
| should, I will leave it up to you to interface it with whatever you
| wish to interface it with.
|
| Have a look at your original question, then gauge for yourself
| how little your current requirements have in common with that
| initial question. This is why I asked for a well-thought out
| specification - which is the first step in any programming effort!
|
|
 
A

Ayush

Thanks Pegasus for your help. I will change the alias name so that they will not
conflict with anything. I will add a X to all the alias. That way i don't have
to remember them again.

--
Ayush [ Be ''?'' Happy ]

For any query, search - www.Google.com
Want to know about a term - http://en.wikipedia.org

Replied To :
-------------------------------------------------------------

| This is not a "bug" as you like to call it but is the direct result
| of your lack of functional specification that I keep mentioning.
| It's often called "scope creep".
|
| You're a programmer. Use a further "find" pipe to suppress
| lines that include the string "*ms"! (if that's what you want,
| which I'm not sure at all).
|
|
|
| "Ayush" <ayushmaan.j[aatt]gmail.com> wrote in message
| | > Thanks for your patience and support. That worked but still there is a bug
| in it
| > that whenever it founds the text (parameter), it opens that website. I
| tested
| > the alias "ms" and it opened every occurrence of ms. It opened these
| sites:
| > http://3d2f.com/programs/1-131-totalsize-download.shtml
| > *ms in programs
| > ms http://www.microsoft.com/
| > *ms in ms
| > msq
| http://search.microsoft.com/results.aspx?mkt=en-US&setlang=en-US&q=query
| > *ms in msq
| >
| > Can you modified the script so that it will not open any ms that is not
| > separate.Example: programs.
| > --
| > Ayush [ Be ''?'' Happy ]
| >
| > For any query, search - www.Google.com
| > Want to know about a term - http://en.wikipedia.org
| >
| > Replied To :
| > -------------------------------------------------------------
| >
| > | > |
| > | "Ayush" <ayushmaan.j[aatt]gmail.com> wrote in message
| > | | > | >
| > | >
| > | >
| > | > Replied To :
| > | > -------------------------------------------------------------
| > | >
| > | > | > | > |
| > | > | "Ayush" <ayushmaan.j[aatt]gmail.com> wrote in message
| > | > | | > | > | >
| > | > | >
| > | > | > Replied To :
| > | > | > -------------------------------------------------------------
| > | > | >
| > | > | > | > | > | > I am thinking of using "if" command for converting aliases in
| urls.
| > | > | >
| > | > | > | > | No problem reading a line from a text file:
| > | > | > | > |
| > | > | > | > | for /f %%a in (c:\url.txt) do set url=%%a
| > | > | > | > | start /b "FireFox" "C:\program files\Mozilla
| > | firefox\firefox.exe"
| > | > | > | www.%url%
| > | > | > | >
| > | > | > | > I have lots of aliases and urls in a single text file. This
| script
| > | > | sets
| > | > | > | the
| > | > | > | > variable URL to the last line in the text file.
| > | > | > | > I have aliases and urls in this format :
| > | > | > | > alias<SPACE>URL
| > | > | >
| > | > | > | >
| > | > | > |
| > | > | >
| > | > |
| > | >
| > |
| >
|
http://www.softpedia.com/get/Authoring-tools/Setup-creators/Nullsoft-Installation-System.shtml
| > | > | > | > jok http://www.jokefile.co.uk
| > | > | > | > AND Can you tell me what actually the for loop is doing ? I
| try to
| > | > | know
| > | > | > | from for
| > | > | > | > /? but cant get it.
| > | > | > | > --
| > | > | > | > Ayush [ Be ''?'' Happy ]
| > | > | > | >
| > | > | > | >
| > | > | > |
| > | > | > | To avoid guessing games, it is best to do this ***before***
| posting:
| > | > | > | 1. Think about your exact requirements (or the nature of the
| > | problem).
| > | > | > | 2. Put it all into the post.
| > | > | > |
| > | > | >
| > | > | >
| > | > | > Sorry about that, i think that was not needed.
| > | > | >
| > | > | >
| > | > | >
| > | > | >
| > | > | > | In your case I ***guess*** that this is what you wish to do do:
| > | > | > | 1. Prompt the user for a keyword, e.g. "jokes".
| > | > | > | 2. Scan a list of URLs for this keyword.
| > | > | > | 3. Extract the appropriate line from the list.
| > | > | > | 4. Launch the selected web page.
| > | > | > | So far you have alluded to this type of action but you
| > | > | > | never actually spelt it out. Is this what you require?
| > | > | >
| > | > | > First, i don't know how to do the above and don't want to do.
| > | > | > I want to take the parameter > then search for that in the text
| file >
| > | If
| > | > | found
| > | > | > then open the browser by giving the URL for the alias.
| > | > | > Now the main question is : Can this be done from script ? I mean :
| > | find
| > | > | the text
| > | > | > > then retrieve the url after the text and space and before the
| new
| > | line.
| > | > | >
| > | > | > --
| > | > | > Ayush [ Be ''?'' Happy ]
| > | > | >
| > | > | >
| > | > |
| > | > | Where does the parameter come from? In the absence of detailed
| > | > | information, here is the raw batch file. It's just two lines long.
| Don't
| > | > | add or omit any single or double quotes or other special characters
| > | > | unless you know exactly what you're doing.
| > | >
| > | > The parameter will come from the address toolbar. I will type like
| this :
| > | > z <alias as a parameter>
| > | >
| > | >
| > | > |
| > | > | @echo off
| > | > | for /F "tokens=2" %%a in ('type url.txt ^| find /i "SomeParameter"')
| do
| > | > | start /b "FireFox" "C:\program files\Mozilla firefox\firefox.exe"
| "%%a"
| > | >
| > | > That script just flashes for a second. I placed a the file in the
| > | directory
| > | > where this script is located and renamed it to url.txt but the script
| just
| > | > flashes away. I changed the SomeParameter to a text that is in the
| text
| > | file but
| > | > it just flashes away. It doesn't even open FireFox.
| > | >
| > | >
| > | >
| > | > --
| > | > Ayush [ Be ''?'' Happy ]
| > | >
| > | >
| > |
| > | 1. Paste these two lines into c:\test.bat:
| > | @echo off
| > | for /F "tokens=2" %%a in ('type c:\url.txt ^| find /i "%1"') do start /b
| > | "FireFox" "C:\program files\Mozilla firefox\firefox.exe" "%%a"
| > |
| > |
| > | 2. Paste the following lines into c:\url.txt:
| > | g3 http://kgiii.info/windows/XP.html
| > | gamess http://www.dodge.com/games/
| > | gcardd http://www.123greetings.com/
| > | gl www.google.com
| > | gla http://www.google.co.in/advanced_search?hl=en
| > | goodiess http://www.filehungry.com/english/showcase/Windows_Software
| > | grantr http://www.us.playstation.com/Content/OGS/SCUS-97328/Site/
| > | greatts http://3d2f.com/programs/1-131-totalsize-download.shtml
| > | helperr
| > |
| >
|
http://www.theglobeandmail.com/serv...ktoptrouble/BNStory/Technology/Troubleshooter
| > | helplinee http://blogs.chron.com/helpline/
| > | hlpn http://www.microsoft.com/wn3/locales/help/help_en-us.htm
| > | inline
| > |
| >
|
http://www.softpedia.com/get/Authoring-tools/Setup-creators/Nullsoft-Installation-System.shtml
| > | jok http://www.jokefile.co.uk
| > | jokeess http://ixpats.com/bestoftheweb/
| > | mmm http://www.actualtools.com/products/index.php#aim
| > | movy http://www.adlabscinemas.com/
| >
| > |
| > | 3. Start a Command Prompt.
| > |
| > | 4. Type this command:
| > | c:\test.bat jokeess
| > |
| > | You will now see that the batch file works very well. Since you
| > | were reluctant to fully define your project when I suggested you
| > | should, I will leave it up to you to interface it with whatever you
| > | wish to interface it with.
| > |
| > | Have a look at your original question, then gauge for yourself
| > | how little your current requirements have in common with that
| > | initial question. This is why I asked for a well-thought out
| > | specification - which is the first step in any programming effort!
| > |
| > |
| >
| >
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top