Posting file name and file contents to remote server via curl command

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I'm trying to write a bash script that would post the name and content of a local file to a remote server via curl.



Local file name has the following format:



/tmp/DeviceID-Date.txt


For eg. 178-20171105.txt.



Remote server: http://myserver.com/insert.php



The remote insert.php script part would then explode the $_POST['filename'] to extract DeviceID and Date, and get the contents of the file through $_POST['filedata'] to store all this info in the server's database (this part I got covered already).



Is that possible?



Note: this is a small text file (max 6 KB). I tried --upload-file and got "405 - HTTP verb used to access this page is not allowed".







share|improve this question






















  • If you want to ensure that the file contents are not disturbed you might want to take a different approach and use curl's --upload-file option to send the content (FYI it uses PUT) and pass the filename in a header (e.g. --header 'filename: DeviceID-Date.txt').
    – B Layer
    Nov 5 '17 at 15:50











  • Try curl -F "file=@/tmp/DeviceID-Date.txt;filename=DeviceID-Date.txt" url. But your server side script must accept content-type multipart/form-data.
    – B Layer
    Nov 5 '17 at 16:22











  • @BLayer tried both your suggestions and got curl: (27) PRNG seeding failed
    – Nino Kay
    Nov 5 '17 at 16:37










  • Alternatively use curl -F "filedata=</tmp/DeviceID-Date.txt" -F "filename=DeviceID-Date.txt" url. This will convert contents of the file to simple text in a text field but obviously won't work with binary files.
    – B Layer
    Nov 5 '17 at 16:39











  • I split them and still got the same error curl: (27) PRNG seeding failed. I wonder why.
    – Nino Kay
    Nov 5 '17 at 16:44














up vote
1
down vote

favorite












I'm trying to write a bash script that would post the name and content of a local file to a remote server via curl.



Local file name has the following format:



/tmp/DeviceID-Date.txt


For eg. 178-20171105.txt.



Remote server: http://myserver.com/insert.php



The remote insert.php script part would then explode the $_POST['filename'] to extract DeviceID and Date, and get the contents of the file through $_POST['filedata'] to store all this info in the server's database (this part I got covered already).



Is that possible?



Note: this is a small text file (max 6 KB). I tried --upload-file and got "405 - HTTP verb used to access this page is not allowed".







share|improve this question






















  • If you want to ensure that the file contents are not disturbed you might want to take a different approach and use curl's --upload-file option to send the content (FYI it uses PUT) and pass the filename in a header (e.g. --header 'filename: DeviceID-Date.txt').
    – B Layer
    Nov 5 '17 at 15:50











  • Try curl -F "file=@/tmp/DeviceID-Date.txt;filename=DeviceID-Date.txt" url. But your server side script must accept content-type multipart/form-data.
    – B Layer
    Nov 5 '17 at 16:22











  • @BLayer tried both your suggestions and got curl: (27) PRNG seeding failed
    – Nino Kay
    Nov 5 '17 at 16:37










  • Alternatively use curl -F "filedata=</tmp/DeviceID-Date.txt" -F "filename=DeviceID-Date.txt" url. This will convert contents of the file to simple text in a text field but obviously won't work with binary files.
    – B Layer
    Nov 5 '17 at 16:39











  • I split them and still got the same error curl: (27) PRNG seeding failed. I wonder why.
    – Nino Kay
    Nov 5 '17 at 16:44












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm trying to write a bash script that would post the name and content of a local file to a remote server via curl.



Local file name has the following format:



/tmp/DeviceID-Date.txt


For eg. 178-20171105.txt.



Remote server: http://myserver.com/insert.php



The remote insert.php script part would then explode the $_POST['filename'] to extract DeviceID and Date, and get the contents of the file through $_POST['filedata'] to store all this info in the server's database (this part I got covered already).



Is that possible?



Note: this is a small text file (max 6 KB). I tried --upload-file and got "405 - HTTP verb used to access this page is not allowed".







share|improve this question














I'm trying to write a bash script that would post the name and content of a local file to a remote server via curl.



Local file name has the following format:



/tmp/DeviceID-Date.txt


For eg. 178-20171105.txt.



Remote server: http://myserver.com/insert.php



The remote insert.php script part would then explode the $_POST['filename'] to extract DeviceID and Date, and get the contents of the file through $_POST['filedata'] to store all this info in the server's database (this part I got covered already).



Is that possible?



Note: this is a small text file (max 6 KB). I tried --upload-file and got "405 - HTTP verb used to access this page is not allowed".









share|improve this question













share|improve this question




share|improve this question








edited Feb 8 at 12:48









Pierre.Vriens

94641015




94641015










asked Nov 5 '17 at 14:29









Nino Kay

61




61











  • If you want to ensure that the file contents are not disturbed you might want to take a different approach and use curl's --upload-file option to send the content (FYI it uses PUT) and pass the filename in a header (e.g. --header 'filename: DeviceID-Date.txt').
    – B Layer
    Nov 5 '17 at 15:50











  • Try curl -F "file=@/tmp/DeviceID-Date.txt;filename=DeviceID-Date.txt" url. But your server side script must accept content-type multipart/form-data.
    – B Layer
    Nov 5 '17 at 16:22











  • @BLayer tried both your suggestions and got curl: (27) PRNG seeding failed
    – Nino Kay
    Nov 5 '17 at 16:37










  • Alternatively use curl -F "filedata=</tmp/DeviceID-Date.txt" -F "filename=DeviceID-Date.txt" url. This will convert contents of the file to simple text in a text field but obviously won't work with binary files.
    – B Layer
    Nov 5 '17 at 16:39











  • I split them and still got the same error curl: (27) PRNG seeding failed. I wonder why.
    – Nino Kay
    Nov 5 '17 at 16:44
















  • If you want to ensure that the file contents are not disturbed you might want to take a different approach and use curl's --upload-file option to send the content (FYI it uses PUT) and pass the filename in a header (e.g. --header 'filename: DeviceID-Date.txt').
    – B Layer
    Nov 5 '17 at 15:50











  • Try curl -F "file=@/tmp/DeviceID-Date.txt;filename=DeviceID-Date.txt" url. But your server side script must accept content-type multipart/form-data.
    – B Layer
    Nov 5 '17 at 16:22











  • @BLayer tried both your suggestions and got curl: (27) PRNG seeding failed
    – Nino Kay
    Nov 5 '17 at 16:37










  • Alternatively use curl -F "filedata=</tmp/DeviceID-Date.txt" -F "filename=DeviceID-Date.txt" url. This will convert contents of the file to simple text in a text field but obviously won't work with binary files.
    – B Layer
    Nov 5 '17 at 16:39











  • I split them and still got the same error curl: (27) PRNG seeding failed. I wonder why.
    – Nino Kay
    Nov 5 '17 at 16:44















If you want to ensure that the file contents are not disturbed you might want to take a different approach and use curl's --upload-file option to send the content (FYI it uses PUT) and pass the filename in a header (e.g. --header 'filename: DeviceID-Date.txt').
– B Layer
Nov 5 '17 at 15:50





If you want to ensure that the file contents are not disturbed you might want to take a different approach and use curl's --upload-file option to send the content (FYI it uses PUT) and pass the filename in a header (e.g. --header 'filename: DeviceID-Date.txt').
– B Layer
Nov 5 '17 at 15:50













Try curl -F "file=@/tmp/DeviceID-Date.txt;filename=DeviceID-Date.txt" url. But your server side script must accept content-type multipart/form-data.
– B Layer
Nov 5 '17 at 16:22





Try curl -F "file=@/tmp/DeviceID-Date.txt;filename=DeviceID-Date.txt" url. But your server side script must accept content-type multipart/form-data.
– B Layer
Nov 5 '17 at 16:22













@BLayer tried both your suggestions and got curl: (27) PRNG seeding failed
– Nino Kay
Nov 5 '17 at 16:37




@BLayer tried both your suggestions and got curl: (27) PRNG seeding failed
– Nino Kay
Nov 5 '17 at 16:37












Alternatively use curl -F "filedata=</tmp/DeviceID-Date.txt" -F "filename=DeviceID-Date.txt" url. This will convert contents of the file to simple text in a text field but obviously won't work with binary files.
– B Layer
Nov 5 '17 at 16:39





Alternatively use curl -F "filedata=</tmp/DeviceID-Date.txt" -F "filename=DeviceID-Date.txt" url. This will convert contents of the file to simple text in a text field but obviously won't work with binary files.
– B Layer
Nov 5 '17 at 16:39













I split them and still got the same error curl: (27) PRNG seeding failed. I wonder why.
– Nino Kay
Nov 5 '17 at 16:44




I split them and still got the same error curl: (27) PRNG seeding failed. I wonder why.
– Nino Kay
Nov 5 '17 at 16:44















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402666%2fposting-file-name-and-file-contents-to-remote-server-via-curl-command%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402666%2fposting-file-name-and-file-contents-to-remote-server-via-curl-command%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay