LinuxQuestions.org
Visit Jeremy's Blog.
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-20-2014, 05:22 AM   #1
cutechaps
LQ Newbie
 
Registered: Feb 2014
Posts: 2

Rep: Reputation: Disabled
curl one liner


Hi

I am trying to write a curl one-liner that will help me to input the password after intiating the upload. Also this curl job needs to run on the background and transfer the verbose output to a file. So we can tail the file and check the status if required.

This is curl command that I am using now.

curl -T "#filename#" -u "username" "https://URL/upload/" -o log.txt -v -k


Thanks
 
Old 02-20-2014, 09:45 AM   #2
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,663
Blog Entries: 10

Rep: Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076
Check out curl_setopt

I use curl_setopt to store "variables" specific to complex curl queries to an openfire remote host inside a .php file:
Yours could go something like this:
PHP Code:
<?php
curl_setopt
($curlCURLOPT_URL"https://URL/upload/");
curl_setopt($curlCURLOPT_HEADER0);
curl_setopt($curlCURLOPT_HTTPAUTHCURLAUTH_ANY);
curl_setopt($curlCURLOPT_USERPWD'username:password');
curl_setopt($curlCURLOPT_RETURNTRANSFER1);
curl_setopt($curlCURLOPT_VERBOSETRUE);
curl_setopt($curlCURLOPT_CAPATH'/etc/pki/tls/certs');
curl_setopt($curlCURLOPT_SSL_VERIFYPEERfalse);
curl_setopt($curlCURLOPT_SSL_VERIFYHOST0);
$data curl_exec($curl);
curl_close($curl);
echo 
$data;  // print the operation in the terminal
?>
and it's executed like so:
Code:
php -f /path/to/myfile.php
I'm not clear if "-v -k" is necessary since this snippet uses CURLOPT_SSL_VERIFYPEER, false.
YMMV

And Welcome to LQ.
 
Old 02-20-2014, 11:21 AM   #3
cutechaps
LQ Newbie
 
Registered: Feb 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks for the reply

But I am looking for simple one liner so that any user enter on the shell prompt.

-Thanks.
 
Old 02-20-2014, 11:59 AM   #4
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,663
Blog Entries: 10

Rep: Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076
http://www.commandlinefu.com/command.../sort-by-votes

suggests that

Code:
curl -T "#filename#" -u username --silent "https://URL/upload/"
upload and logging?

Maybe
Code:
$(curl -T "#filename#" -u username --silent "https://URL/upload/") -o log.txt -v -k
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Fixed one-liner timer. stf92 General 7 10-18-2013 01:47 AM
one liner to create a value and then search casperdaghost Linux - Software 3 11-10-2009 01:08 AM
awk one liner help niknak Linux - Newbie 1 05-07-2009 05:52 AM
IP Forward one-liner? JoeBleaux Linux - Networking 1 04-27-2009 11:24 AM
cURL: Server has many IPs, how would I make a cURL script use those IPs to send data? guest Programming 0 04-11-2009 12:42 PM


All times are GMT -5. The time now is 06:39 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration