LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-23-2018, 12:50 PM   #1
biggizod
LQ Newbie
 
Registered: Feb 2018
Posts: 2

Rep: Reputation: Disabled
red hat script with curl


hi guys , i am trying to create script with curl command:
curl -v "http://x.x.x.x......"
sleep 5

about 300 of this commands, it will help me to remotely log off and login cisco phones. How can I run that text file/script?
Is it just : file [file location] ?
should i make it exe ? please share steps
thank you
 
Old 02-23-2018, 12:55 PM   #2
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,963

Rep: Reputation: 271Reputation: 271Reputation: 271
Code:
#! /bin/bash
curl -v "..."
sleep 5
You don't have to give it any special name.

You need to make it executable with:
Code:
chmod +x myscript
and specify the path, for instance $HOME/bin/myscript, if that's where it is, or put it in the path.

You can discover the path with:
Code:
echo $PATH
 
Old 02-23-2018, 01:00 PM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Yes you should put your commands into a file and make that file executable. You can run that file, providing you are in the directory where it is located, or if it resides in a directory which is in your $PATH variable.

There is also some syntax relevant to bash scripts which you need to be aware of.

Recommend you use The Bash Beginners Guide as a general guide to learning bash scripting.

A first script example is shown in Section 1.5.5: An example Bash script: mysystem.sh and this should show you a great example in line with what you're doing here and help you with the syntax I'm referring to.
 
Old 02-23-2018, 01:56 PM   #4
biggizod
LQ Newbie
 
Registered: Feb 2018
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thank you guys. Is there a way to get logs, output results ?
 
Old 02-23-2018, 02:09 PM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by biggizod View Post
Thank you guys. Is there a way to get logs, output results ?
Hi,

Back to the reference Appendix A: Shell Features where you'll find the input/output redirectors. There are examples throughout that document if you search for redirect. It is a matter of choosing between ">" for redirect to file (new), or ">>" redirect to file (append)
 
Old 02-24-2018, 12:20 AM   #6
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,963

Rep: Reputation: 271Reputation: 271Reputation: 271
Quote:
Originally Posted by rtmistler View Post
Y You can run that file, providing you are in the directory where it is located,
Unlike MS-DOS the current directory is not in the path in Linux. You can put . in the path, but it isn't by default. A Unix instructor told me it was a bad idea. I can't recall the reason; I'll try to.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Red Hat powers cloud-scale DevOps with the general availability of Red Hat Cloud Suite and Red Hat OpenStack Platform 8 LXer Syndicated Linux News 0 04-20-2016 04:20 PM
Problem installing Curl in my Red Hat Server littlelorly Linux - Newbie 1 05-27-2012 06:56 PM
cURL: Server has many IPs, how would I make a cURL script use those IPs to send data? guest Programming 0 04-11-2009 11:42 AM
need help with /script/citrix/red hat 7.0 Joachim Linux - Software 7 06-30-2003 04:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration