Posting file name and file contents to remote server via curl command
Clash 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".
bash embedded curl
 |Â
show 1 more comment
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".
bash embedded curl
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
Trycurl -F "file=@/tmp/DeviceID-Date.txt;filename=DeviceID-Date.txt" url
. But your server side script must accept content-typemultipart/form-data
.
â B Layer
Nov 5 '17 at 16:22
@BLayer tried both your suggestions and gotcurl: (27) PRNG seeding failed
â Nino Kay
Nov 5 '17 at 16:37
Alternatively usecurl -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 errorcurl: (27) PRNG seeding failed
. I wonder why.
â Nino Kay
Nov 5 '17 at 16:44
 |Â
show 1 more comment
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".
bash embedded curl
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".
bash embedded curl
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
Trycurl -F "file=@/tmp/DeviceID-Date.txt;filename=DeviceID-Date.txt" url
. But your server side script must accept content-typemultipart/form-data
.
â B Layer
Nov 5 '17 at 16:22
@BLayer tried both your suggestions and gotcurl: (27) PRNG seeding failed
â Nino Kay
Nov 5 '17 at 16:37
Alternatively usecurl -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 errorcurl: (27) PRNG seeding failed
. I wonder why.
â Nino Kay
Nov 5 '17 at 16:44
 |Â
show 1 more comment
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
Trycurl -F "file=@/tmp/DeviceID-Date.txt;filename=DeviceID-Date.txt" url
. But your server side script must accept content-typemultipart/form-data
.
â B Layer
Nov 5 '17 at 16:22
@BLayer tried both your suggestions and gotcurl: (27) PRNG seeding failed
â Nino Kay
Nov 5 '17 at 16:37
Alternatively usecurl -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 errorcurl: (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
 |Â
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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-typemultipart/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